<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>星格 - 探索你的人格与运势</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    
    <!-- 配置Tailwind自定义主题 -->
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#6C5CE7', // 主紫色
                        secondary: '#FD79A8', // 辅助粉色
                        accent: '#00B894', // 强调色
                        dark: '#2D3436',
                        light: '#F8F9FA'
                    },
                    fontFamily: {
                        sans: ['Inter', 'system-ui', 'sans-serif'],
                    },
                }
            }
        }
    </script>
    
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .text-shadow {
                text-shadow: 0 2px 4px rgba(0,0,0,0.1);
            }
            .bg-stars {
                background-image: radial-gradient(circle, #ffffff 1px, transparent 1px);
                background-size: 24px 24px;
            }
            .tab-active {
                color: #6C5CE7;
                border-bottom-width: 2px;
                border-bottom-style: solid;
                border-bottom-color: #6C5CE7;
            }
            .card-hover {
                transition-property: all;
                transition-duration: 300ms;
            }
            .card-hover:hover {
                box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
                transform: translateY(-0.25rem);
            }
            .mascot-bounce {
                animation: bounce 2s infinite;
            }
            .mascot-float {
                animation: float 3s ease-in-out infinite;
            }
            .mascot-pulse {
                animation: pulse 2s infinite;
            }
                    .bg-gradient-custom {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        /* 星座选择动画 */
        @keyframes zodiacSelect {
            0% {
                transform: scale(1);
            }
            50% {
                transform: scale(1.1);
            }
            100% {
                transform: scale(1.05);
            }
        }
        
        .zodiac-btn:active {
            transform: scale(0.95);
            transition: transform 0.1s ease;
        }
        
        .zodiac-btn.ring-4 {
            box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.3);
        }
            @keyframes bounce {
                0%, 100% { transform: translateY(0); }
                50% { transform: translateY(-10px); }
            }
            @keyframes float {
                0%, 100% { transform: translateY(0); }
                50% { transform: translateY(-8px); }
            }
            @keyframes pulse {
                0%, 100% { transform: scale(1); }
                50% { transform: scale(1.05); }
            }
            @keyframes slideInUp {
                0% {
                    transform: translateY(10px);
                    opacity: 0;
                }
                100% {
                    transform: translateY(0);
                    opacity: 1;
                }
            }
            
            @keyframes spin {
                from {
                    transform: rotate(0deg);
                }
                to {
                    transform: rotate(360deg);
                }
            }
            
            @keyframes fadeInScale {
                from {
                    opacity: 0;
                    transform: scale(0.9) translateY(10px);
                }
                to {
                    opacity: 1;
                    transform: scale(1) translateY(0);
                }
            }
            
            .recommendation-item {
                animation: fadeInScale 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
            }
            
            .refresh-btn {
                transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            }
            
            .refresh-btn:hover {
                transform: scale(1.05);
                box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
            }
            
            .refresh-btn:active {
                transform: scale(0.95);
            }
        }
    </style>
</head>
<body class="bg-gray-50 text-dark min-h-screen flex flex-col">


    <!-- 主内容区 -->
    <main class="flex-1 pt-5 pb-20 relative">
        <!-- 全局背景渐变 - 覆盖整个主内容区 -->
        <div class="fixed inset-0 w-full h-full" style="background: linear-gradient(135deg, #FDCFE8 0%, #E4C1F9 50%, #BDE0FE 100%); z-index: -1;"></div>

        <!-- 测试 Tab -->
        <div id="test-tab" class="tab-content active">
            
            <div class="container mx-auto px-4 py-5 relative z-10">
                <!-- 页面标题 -->
                <div class="text-center mb-6">
                    <h1 class="text-2xl font-bold text-gray-800 mb-2">探索你的人格与星座</h1>
                    <p class="text-gray-600 text-sm">通过科学的测试了解自己，探索星座的奥秘</p>
                </div>
                
                <!-- 用户欢迎区 -->
                <div class="bg-gradient-custom rounded-2xl p-5 mb-6 text-white relative overflow-hidden shadow-xl">
                    <div class="absolute top-0 right-0 w-24 h-24 bg-white/10 rounded-full -mr-12 -mt-12"></div>
                    <div class="absolute bottom-0 left-0 w-16 h-16 bg-white/10 rounded-full -ml-8 -mb-8"></div>
                    
                    <div class="relative z-10">
                        <h2 class="text-xl font-bold mb-1">你好，探索者</h2>
                        <p class="text-white/80 text-sm mb-4">今天适合探索自我的一天</p>
                        
                        <div class="flex items-center">
                            <div class="w-10 h-10 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center mr-3">
                                <i class="fa fa-lightbulb-o"></i>
                            </div>
                            <div>
                                <p class="text-xs text-white/80">今日启示</p>
                                <p class="text-sm font-medium">"认识自己是智慧的开始"</p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 底部弹出 - 星座选择器 -->
                <!-- 已移至页面底部全局区域，避免被 Tab hidden 影响 -->

                

                <!-- 测试区域 -->
                <div class="mb-8">
                    <h2 class="text-lg font-bold mb-5 text-center text-gray-800">选择你的测试</h2>
                    
                    <!-- 星座测试模块 -->
                    <div id="zodiac-module" class="bg-gradient-to-br from-white to-yellow-50/50 rounded-2xl shadow-lg p-5 mb-6 border border-yellow-100/50 cursor-pointer hover:shadow-xl transition-all duration-300 backdrop-blur-sm">
                        <div class="mb-4">
                            <h3 class="text-lg font-semibold flex items-center text-gray-800">
                                <div class="w-10 h-10 rounded-full bg-gradient-to-br from-yellow-100 to-orange-100 flex items-center justify-center mr-3 shadow-md">
                                    <i class="fa fa-star text-yellow-500 text-lg"></i>
                                </div>
                                星座相关测试
                            </h3>
                        </div>
                        <p class="text-gray-600 text-sm mb-4">探索星座的奥秘，了解你与他人的匹配度，发现星座背后的深层含义。</p>
                        <div class="flex items-center text-xs text-gray-500">
                            <i class="fa fa-magic mr-1"></i>
                            <span>基于传统占星学理论</span>
                        </div>
                    </div>
                    
                    <!-- 人格测试模块 -->
                    <div id="personality-module" class="bg-gradient-to-br from-white to-blue-50/50 rounded-2xl shadow-lg p-5 mb-6 border border-blue-100/50 cursor-pointer hover:shadow-xl transition-all duration-300 backdrop-blur-sm">
                        <div class="mb-4">
                            <h3 class="text-lg font-semibold flex items-center text-gray-800">
                                <div class="w-10 h-10 rounded-full bg-gradient-to-br from-primary/20 to-blue-500/30 flex items-center justify-center mr-3 shadow-md">
                                    <i class="fa fa-user-circle-o text-primary text-lg"></i>
                                </div>
                                MBTI人格测试
                            </h3>
                        </div>
                        <p class="text-gray-600 text-sm mb-4">通过科学的MBTI理论，深入了解你的人格类型特征，发现自己的优势和潜力。</p>
                        <div class="flex items-center text-xs text-gray-500">
                            <i class="fa fa-users mr-1"></i>
                            <span>已有 100万+ 用户完成测试</span>
                        </div>
                    </div>
                    
                    
                </div>

                <!-- 推荐内容区（小知识三栏） -->
                <div class="bg-gradient-to-br from-white to-purple-50/50 rounded-2xl shadow-lg p-5 border border-purple-100/50 backdrop-blur-sm">
                    <div class="flex justify-between items-center mb-4">
                        <h3 class="text-base font-bold text-gray-800 flex items-center">
                            <div class="w-8 h-8 rounded-full bg-gradient-to-br from-purple-100 to-purple-200 flex items-center justify-center mr-2 shadow-sm">
                                <i class="fa fa-lightbulb-o text-purple-600 text-sm"></i>
                            </div>
                            今日推荐
                        </h3>
                        <button id="refresh-recommendations" class="inline-flex items-center px-3 py-1.5 text-xs rounded-full border border-purple-200 bg-white/70 hover:bg-purple-50 text-purple-700 transition">
                            <i id="refresh-icon" class="fa fa-refresh text-xs mr-1"></i>
                            <span id="refresh-text">换一批</span>
                        </button>
                    </div>

                    <div class="grid grid-cols-1 gap-3">
                        <!-- 入口：星座每日小挑战 (移到首位) -->
                        <div class="text-left bg-white/60 rounded-xl p-4 border border-purple-100/40 hover:bg-white transition flex items-start gap-3 cursor-pointer" onclick="window.location.href='daily-challenge.html'">
                            <div class="w-9 h-9 rounded-full bg-gradient-to-br from-emerald-100 to-green-100 flex items-center justify-center text-emerald-600 flex-shrink-0"><i class="fa fa-flag"></i></div>
                            <div>
                                <div class="text-sm font-semibold text-gray-800">星座每日小挑战</div>
                                <div class="text-xs text-gray-600 mt-1 line-clamp-2">每天 1 个与星座相关的小挑战 · 低门槛 · 即时反馈 · 提升完成感</div>
                            </div>
                            <i class="fa fa-angle-right ml-auto text-gray-400"></i>
                        </div>
                        <!-- 星座相关小知识 -->
                        <button id="rec-zodiac" class="text-left bg-white/60 rounded-xl p-4 border border-purple-100/40 hover:bg-white transition flex items-start gap-3">
                            <div class="w-9 h-9 rounded-full bg-gradient-to-br from-amber-100 to-orange-100 flex items-center justify-center text-amber-600 flex-shrink-0"><i class="fa fa-star"></i></div>
                            <div>
                                <div class="text-sm font-semibold text-gray-800">星座相关小知识</div>
                                <div id="rec-zodiac-line" class="text-xs text-gray-600 mt-1 line-clamp-1"></div>
                            </div>
                            <i class="fa fa-angle-right ml-auto text-gray-400"></i>
                        </button>

                        <!-- 人格相关小知识 -->
                        <button id="rec-personality" class="text-left bg-white/60 rounded-xl p-4 border border-purple-100/40 hover:bg-white transition flex items-start gap-3">
                            <div class="w-9 h-9 rounded-full bg-gradient-to-br from-primary/15 to-blue-200/60 flex items-center justify-center text-primary flex-shrink-0"><i class="fa fa-user-o"></i></div>
                            <div>
                                <div class="text-sm font-semibold text-gray-800">人格相关小知识</div>
                                <div id="rec-personality-line" class="text-xs text-gray-600 mt-1 line-clamp-1"></div>
                            </div>
                            <i class="fa fa-angle-right ml-auto text-gray-400"></i>
                        </button>
                        
                    </div>
                </div>

                <!-- 小知识半屏模态 -->
                <div id="recommend-modal" class="fixed inset-0 bg-black/50 z-50 hidden">
                    <div class="absolute bottom-0 left-0 right-0 bg-white rounded-t-3xl p-6 transform translate-y-full transition-transform duration-300 max-h-[70vh] overflow-y-auto">
                        <div class="flex items-center justify-between mb-4">
                            <h3 id="recommend-modal-title" class="text-xl font-bold text-gray-800">小知识</h3>
                            <button id="close-recommend-modal" class="w-8 h-8 rounded-full bg-gray-100 flex items-center justify-center hover:bg-gray-200 transition-colors"><i class="fa fa-times text-gray-600"></i></button>
                        </div>
                        <div id="recommend-modal-content" class="space-y-2"></div>
                    </div>
                </div>

                <!-- 模态弹窗 - 人格测试列表 -->
                <div id="personality-modal" class="fixed inset-0 bg-black/50 z-50 hidden">
                    <div class="absolute bottom-0 left-0 right-0 bg-white rounded-t-3xl p-6 transform translate-y-full transition-transform duration-300">
                        <div class="flex items-center justify-between mb-6">
                            <h3 class="text-xl font-bold text-gray-800">MBTI人格测试</h3>
                            <button id="close-personality-modal" class="w-8 h-8 rounded-full bg-gray-100 flex items-center justify-center hover:bg-gray-200 transition-colors">
                                <i class="fa fa-times text-gray-600"></i>
                            </button>
                        </div>
                        
                        <div class="space-y-4 mb-6">
                            <div class="bg-gradient-to-r from-primary/5 to-primary/10 rounded-xl p-4 border border-primary/20">
                                <div class="flex justify-between items-center">
                                    <div>
                                        <h4 class="font-semibold text-gray-800 mb-1">完整MBTI测试</h4>
                                        <p class="text-sm text-gray-600 mb-2">93题 · 25-30分钟 · 深入解析你的人格类型</p>
                                        <div class="flex items-center text-xs text-gray-500">
                                            <i class="fa fa-users mr-1"></i>
                                            <span>100万人已测</span>
                                        </div>
                                    </div>
                                    <button onclick="window.location.href='mbti-test.html'" class="bg-primary text-white px-4 py-2 rounded-lg text-sm hover:bg-primary/90 transition-colors">
                                        开始测试
                                    </button>
                                </div>
                            </div>
                            
                            <div class="bg-gradient-to-r from-blue-500/5 to-blue-500/10 rounded-xl p-4 border border-blue-500/20">
                                <div class="flex justify-between items-center">
                                    <div>
                                        <h4 class="font-semibold text-gray-800 mb-1">快速MBTI测试</h4>
                                        <p class="text-sm text-gray-600 mb-2">48题 · 10分钟 · 基础解析</p>
                                        <div class="flex items-center text-xs text-gray-500">
                                            <i class="fa fa-clock-o mr-1"></i>
                                            <span>快速版本</span>
                                        </div>
                                    </div>
                                    <button onclick="window.location.href='quick-mbti-test.html'" class="bg-blue-500 text-white px-4 py-2 rounded-lg text-sm hover:bg-blue-600 transition-colors">
                                        开始测试
                                    </button>
                                </div>
                            </div>
                            
                            <div class="bg-gradient-to-r from-purple-500/5 to-purple-500/10 rounded-xl p-4 border border-purple-500/20">
                                <div class="flex justify-between items-center">
                                    <div>
                                        <h4 class="font-semibold text-gray-800 mb-1">隐藏人格测试</h4>
                                        <p class="text-sm text-gray-600 mb-2">30题 · 发现你的潜在特质</p>
                                        <div class="flex items-center text-xs text-gray-500">
                                            <i class="fa fa-moon-o mr-1"></i>
                                            <span>探索隐藏面</span>
                                        </div>
                                    </div>
                                    <button onclick="window.location.href='hidden-personality-test.html'" class="bg-purple-500 text-white px-4 py-2 rounded-lg text-sm hover:bg-purple-600 transition-colors">
                                        开始测试
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 模态弹窗 - 星座测试列表 -->
                <div id="zodiac-modal" class="fixed inset-0 bg-black/50 z-50 hidden">
                    <div class="absolute bottom-0 left-0 right-0 bg-white rounded-t-3xl p-6 transform translate-y-full transition-transform duration-300">
                        <div class="flex items-center justify-between mb-6">
                            <h3 class="text-xl font-bold text-gray-800">星座相关测试</h3>
                            <button id="close-zodiac-modal" class="w-8 h-8 rounded-full bg-gray-100 flex items-center justify-center hover:bg-gray-200 transition-colors">
                                <i class="fa fa-times text-gray-600"></i>
                            </button>
                        </div>
                        
                        <div class="space-y-4 mb-6">
                            <div class="bg-gradient-to-r from-yellow-500/5 to-yellow-500/10 rounded-xl p-4 border border-yellow-500/20">
                                <div class="flex justify-between items-center">
                                    <div>
                                        <h4 class="font-semibold text-gray-800 mb-1">星座配对测试</h4>
                                        <p class="text-sm text-gray-600 mb-2">测试你与他人的星座匹配度</p>
                                        <div class="flex items-center text-xs text-gray-500">
                                            <i class="fa fa-star mr-1"></i>
                                            <span>星座奥秘</span>
                                        </div>
                                    </div>
                                    <button onclick="window.location.href='zodiac-compatibility.html'" class="bg-yellow-500 text-white px-4 py-2 rounded-lg text-sm hover:bg-yellow-600 transition-colors">
                                        开始测试
                                    </button>
                                </div>
                            </div>
                            
                            <div class="bg-gradient-to-r from-indigo-500/5 to-indigo-500/10 rounded-xl p-4 border border-indigo-500/20">
                                <div class="flex justify-between items-center">
                                    <div>
                                        <h4 class="font-semibold text-gray-800 mb-1">上升星座测算</h4>
                                        <p class="text-sm text-gray-600 mb-2">根据出生时间计算你的上升星座</p>
                                        <div class="flex items-center text-xs text-gray-500">
                                            <i class="fa fa-compass mr-1"></i>
                                            <span>精确计算</span>
                                        </div>
                                    </div>
                                    <button onclick="window.location.href='ascendant-calculator.html'" class="bg-indigo-500 text-white px-4 py-2 rounded-lg text-sm hover:bg-indigo-600 transition-colors">
                                        开始测算
                                    </button>
                                </div>
                            </div>

                            <div class="bg-gradient-to-r from-rose-500/5 to-rose-500/10 rounded-xl p-4 border border-rose-500/20">
                                <div class="flex justify-between items-center">
                                    <div>
                                        <h4 class="font-semibold text-gray-800 mb-1">星座默契测试</h4>
                                        <p class="text-sm text-gray-600 mb-2">和好友 / 家人互动 · 双人默契测试</p>
                                        <div class="flex items-center text-xs text-gray-500">
                                            <i class="fa fa-heart mr-1"></i>
                                            <span>互动更有趣</span>
                                        </div>
                                    </div>
                                    <button onclick="window.location.href='zodiac-harmony-test.html'" class="bg-rose-500 text-white px-4 py-2 rounded-lg text-sm hover:bg-rose-600 transition-colors">
                                        开始测试
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 模态弹窗 - 伴侣测试列表 -->
                <div id="partner-modal" class="fixed inset-0 bg-black/50 z-50 hidden">
                    <div class="absolute bottom-0 left-0 right-0 bg-white rounded-t-3xl p-6 transform translate-y-full transition-transform duration-300">
                        <div class="flex items-center justify-between mb-6">
                            <h3 class="text-xl font-bold text-gray-800">伴侣测试</h3>
                            <button id="close-partner-modal" class="w-8 h-8 rounded-full bg-gray-100 flex items-center justify-center hover:bg-gray-200 transition-colors">
                                <i class="fa fa-times text-gray-600"></i>
                            </button>
                        </div>
                        
                        <div class="space-y-4 mb-6">
                            <div class="bg-gradient-to-r from-secondary/5 to-secondary/10 rounded-xl p-4 border border-secondary/20">
                                <div class="flex justify-between items-center">
                                    <div>
                                        <h4 class="font-semibold text-gray-800 mb-1">爱情配对测试</h4>
                                        <p class="text-sm text-gray-600 mb-2">15题 · 测试你与伴侣的匹配度</p>
                                        <div class="flex items-center text-xs text-gray-500">
                                            <i class="fa fa-heart mr-1"></i>
                                            <span>85万人已测</span>
                                        </div>
                                    </div>
                                    <button onclick="window.location.href='love-test.html'" class="bg-secondary text-white px-4 py-2 rounded-lg text-sm hover:bg-secondary/90 transition-colors">
                                        开始测试
                                    </button>
                                </div>
                            </div>
                            
                            <div class="bg-gradient-to-r from-purple-500/5 to-purple-500/10 rounded-xl p-4 border border-purple-500/20">
                                <div class="flex justify-between items-center">
                                    <div>
                                        <h4 class="font-semibold text-gray-800 mb-1">灵魂伴侣契合度测试</h4>
                                        <p class="text-sm text-gray-600 mb-2">12题 · 深度分析你们的精神契合度</p>
                                        <div class="flex items-center text-xs text-gray-500">
                                            <i class="fa fa-magic mr-1"></i>
                                            <span>灵魂匹配</span>
                                        </div>
                                    </div>
                                    <button onclick="window.location.href='soulmate-test.html'" class="bg-purple-500 text-white px-4 py-2 rounded-lg text-sm hover:bg-purple-600 transition-colors">
                                        开始测试
                                    </button>
                                </div>
                            </div>

                            <div class="bg-gradient-to-r from-rose-500/5 to-rose-500/10 rounded-xl p-4 border border-rose-500/20">
                                <div class="flex justify-between items-center">
                                    <div>
                                        <h4 class="font-semibold text-gray-800 mb-1">自我恋爱脑程度测试</h4>
                                        <p class="text-sm text-gray-600 mb-2">12题 · 评估你对恋爱的投入与理性平衡</p>
                                        <div class="flex items-center text-xs text-gray-500">
                                            <i class="fa fa-heartbeat mr-1"></i>
                                            <span>了解你的恋爱倾向</span>
                                        </div>
                                    </div>
                                    <button onclick="window.location.href='love-brain-test.html'" class="bg-rose-500 text-white px-4 py-2 rounded-lg text-sm hover:bg-rose-600 transition-colors">
                                        开始测试
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 页面装饰元素 -->
                <div class="text-center mt-8 mb-4">
                    <div class="inline-flex items-center space-x-2 text-gray-400 text-xs">
                        <div class="w-2 h-2 rounded-full bg-gradient-to-r from-primary to-secondary"></div>
                        <span>探索更多可能</span>
                        <div class="w-2 h-2 rounded-full bg-gradient-to-r from-secondary to-primary"></div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 运势 Tab -->
        <div id="fortune-tab" class="tab-content hidden">
            <!-- 装饰元素 -->
            <div class="fixed inset-0 overflow-hidden pointer-events-none" style="z-index: 0;">
                <div class="stars absolute inset-0 opacity-20"></div>
                <div class="absolute top-1/3 -left-10 w-96 h-96 bg-amber-200/20 rounded-full blur-3xl"></div>
                <div class="absolute -bottom-10 right-0 w-[28rem] h-[28rem] bg-rose-200/20 rounded-full blur-3xl"></div>
            </div>

            <style>
                .stars { background-image: radial-gradient(white 1px, transparent 1px); background-size: 26px 26px; animation: twinkle 8s infinite alternate; }
                @keyframes twinkle { 0% { opacity: .1 } 100% { opacity: .3 } }
                /* 精简模式样式：收紧留白与隐藏部分拓展块 */
                #fortune-tab.compact-mode #daily-extra,
                #fortune-tab.compact-mode #weekly-section,
                #fortune-tab.compact-mode #monthly-section,
                #fortune-tab.compact-mode #yearly-section {
                    display: none !important;
                }
                #fortune-tab.compact-mode .mb-6 { margin-bottom: 0.75rem !important; }
                #fortune-tab.compact-mode #fortune-title { font-size: 0.95rem !important; }
                #fortune-tab.compact-mode #fortune-card { padding: 1rem !important; }
            </style>
            
            <div class="container mx-auto px-4 py-5 relative z-10">
                <!-- 顶部标题 -->
                <div class="text-center mb-6">
                    <h1 class="text-2xl font-bold text-gray-800 mb-1">每日运势</h1>
                    <p class="text-gray-600 text-sm">精致卡片 · 柔和配色 · 更专注的阅读体验</p>
                </div>
                
                <!-- 星座选择器（简洁圆角胶囊） -->
                <div class="bg-white/70 backdrop-blur-sm border border-amber-100 rounded-2xl shadow-sm p-4 mb-5">
                    <div class="flex items-center justify-between mb-3">
                        <h3 class="text-sm font-medium text-gray-800 flex items-center">
                            <span class="w-2 h-2 rounded-full bg-gradient-to-r from-amber-400 to-orange-400 mr-2"></span>
                        选择你的星座
                    </h3>
                        <span class="text-xs text-gray-500" id="selector-date">
                            <i class="fa fa-calendar-o mr-1"></i>
                        </span>
                                </div>
                    <div>
                        <button id="open-zodiac-picker" class="w-full flex items-center justify-between bg-white rounded-xl border border-amber-100 px-4 py-3 hover:shadow transition">
                            <div class="flex items-center">
                                <div id="selected-zodiac-avatar" class="w-9 h-9 rounded-full overflow-hidden mr-3 shadow-sm">
                                    <img id="selected-zodiac-img" src="assets/zodiac/aries.svg" alt="白羊座" class="w-full h-full object-cover"/>
                                </div>
                                <div>
                                    <div id="selected-zodiac-name" class="text-sm font-medium text-gray-800">白羊座</div>
                                    <div id="selected-zodiac-range" class="text-[11px] text-gray-500">3.21-4.19</div>
                                </div>
                            </div>
                            <i class="fa fa-angle-right text-gray-400"></i>
                        </button>
                    </div>
                                </div>

                <!-- 时间范围切换 -->
                <div class="flex mb-6 overflow-x-auto pb-2 gap-2 items-center justify-between">
                    <div class="flex gap-2">
                    <button id="btn-range-today" data-range="today" class="range-btn whitespace-nowrap px-4 py-2.5 bg-gradient-to-r from-primary to-secondary text-white rounded-full text-sm shadow relative overflow-hidden group">
                        <span class="relative z-10 flex items-center"><i class="fa fa-sun-o mr-1.5 text-yellow-200"></i>今日</span>
                        <span class="absolute inset-0 bg-white/15 scale-x-0 origin-left group-hover:scale-x-100 transition-transform duration-300"></span>
                            </button>
                    <button id="btn-range-week" data-range="week" class="range-btn whitespace-nowrap px-4 py-2.5 bg-white/70 rounded-full text-sm border border-amber-100 hover:bg-amber-50 transition"><span class="flex items-center"><i class="fa fa-calendar-o mr-1.5 text-amber-500"></i>本周</span></button>
                    <button id="btn-range-month" data-range="month" class="range-btn whitespace-nowrap px-4 py-2.5 bg-white/70 rounded-full text-sm border border-amber-100 hover:bg-amber-50 transition"><span class="flex items-center"><i class="fa fa-calendar mr-1.5 text-orange-500"></i>本月</span></button>
                    <button id="btn-range-year" data-range="year" class="range-btn whitespace-nowrap px-4 py-2.5 bg-white/70 rounded-full text-sm border border-amber-100 hover:bg-amber-50 transition"><span class="flex items-center"><i class="fa fa-calendar-check-o mr-1.5 text-rose-500"></i>今年</span></button>
                    </div>
                    <button id="toggle-compact" class="whitespace-nowrap px-3 py-2 bg-white/80 rounded-full text-xs border border-amber-100 hover:bg-amber-50 transition"><i class="fa fa-compress mr-1 text-amber-500"></i>精简模式</button>
                </div>
                        
                <!-- 运势详情卡片（更精致，更留白） -->
                <div id="fortune-card" class="bg-white/75 backdrop-blur border border-amber-100 rounded-2xl shadow p-6 relative overflow-hidden">
                    <div class="absolute -right-8 -top-8 w-40 h-40 bg-gradient-to-br from-amber-100 to-orange-100 rounded-full"></div>
                    <div class="absolute -left-10 -bottom-10 w-28 h-28 bg-gradient-to-br from-rose-100 to-amber-100 rounded-full"></div>
                    
                    <div class="relative z-10">
                        <div class="flex items-center justify-between mb-4">
                            <h3 id="fortune-title" class="text-base font-semibold text-gray-800 flex items-center">
                                <span class="w-2 h-2 bg-gradient-to-r from-primary to-secondary rounded-full mr-2"></span>
                                白羊座 今日运势
                            </h3>
                            <div class="text-right">
                                <div class="text-xs text-gray-400"><i class="fa fa-refresh mr-1"></i>更新于 06:00</div>
                                <div class="text-[10px] text-gray-400" id="fortune-date"></div>
                            </div>
                        </div>
                        
                        <div class="grid grid-cols-2 gap-3 mb-5">
                            <div class="bg-white rounded-xl p-3 border border-amber-100 shadow-sm flex flex-col items-center justify-center text-center gap-1 min-h-[84px]">
                                <p class="text-xs text-gray-600">整体</p>
                                <div id="overall-stars" class="flex items-center gap-0.5 text-amber-500 text-[12px] leading-none whitespace-nowrap"></div>
                            </div>
                            <div class="bg-white rounded-xl p-3 border border-amber-100 shadow-sm flex flex-col items-center justify-center text-center gap-1 min-h-[84px]">
                                <p class="text-xs text-gray-600">爱情</p>
                                <div id="love-stars" class="flex items-center gap-0.5 text-pink-500 text-[12px] leading-none whitespace-nowrap"></div>
                            </div>
                            <div class="bg-white rounded-xl p-3 border border-amber-100 shadow-sm flex flex-col items-center justify-center text-center gap-1 min-h-[84px]">
                                <p class="text-xs text-gray-600">事业</p>
                                <div id="career-stars" class="flex items-center gap-0.5 text-sky-500 text-[12px] leading-none whitespace-nowrap"></div>
                            </div>
                            <div class="bg-white rounded-xl p-3 border border-amber-100 shadow-sm flex flex-col items-center justify-center text-center gap-1 min-h-[84px]">
                                <p class="text-xs text-gray-600">财运</p>
                                <div id="wealth-stars" class="flex items-center gap-0.5 text-emerald-600 text-[12px] leading-none whitespace-nowrap"></div>
                            </div>
                        </div>
                    
                        
                    
                    <div>
                            <h4 class="font-medium text-sm mb-2 flex items-center text-gray-800"><i class="fa fa-magic text-emerald-500 mr-2"></i>幸运提示</h4>
                            <div class="flex flex-wrap gap-2">
                                <span id="lucky-color" class="px-3 py-2 rounded-full text-xs border border-rose-200 bg-rose-50 text-rose-700"></span>
                                <span id="lucky-number" class="px-3 py-2 rounded-full text-xs border border-amber-200 bg-amber-50 text-amber-700"></span>
                                <span id="lucky-direction" class="px-3 py-2 rounded-full text-xs border border-sky-200 bg-sky-50 text-sky-700"></span>
                            </div>
                        </div>

                        <!-- 日运补充信息：幸运时间、宜、忌 -->
                        <div id="daily-extra" class="mt-4 space-y-3">
                            <div class="bg-white rounded-xl p-4 border border-emerald-100">
                                <h4 class="font-medium text-sm mb-1 flex items-center text-gray-800">
                                    <i class="fa fa-clock-o text-emerald-500 mr-2"></i>幸运时间
                                </h4>
                                <p id="lucky-time" class="text-xs text-gray-600"></p>
                            </div>
                            <div class="grid grid-cols-1 gap-3 sm:grid-cols-2">
                                <div class="bg-white rounded-xl p-4 border border-blue-100">
                                    <h4 class="font-medium text-sm mb-1 flex items-center text-blue-700"><i class="fa fa-check-circle text-blue-500 mr-2"></i>宜</h4>
                                    <ul id="do-list" class="list-disc list-inside text-xs text-gray-600 space-y-1"></ul>
                                </div>
                                <div class="bg-white rounded-xl p-4 border border-rose-100">
                                    <h4 class="font-medium text-sm mb-1 flex items-center text-rose-700"><i class="fa fa-ban text-rose-500 mr-2"></i>忌</h4>
                                    <ul id="dont-list" class="list-disc list-inside text-xs text-gray-600 space-y-1"></ul>
                                </div>
                            </div>
                        </div>

                        <!-- 周运：趋势与关键时间点 -->
                        <div id="weekly-section" class="mt-4 space-y-3 hidden">
                            <div class="grid grid-cols-1 gap-3 sm:grid-cols-3">
                                <div class="bg-white rounded-xl p-4 border border-amber-100">
                                    <h4 class="font-medium text-sm mb-1 flex items-center text-pink-700"><i class="fa fa-heart text-pink-500 mr-2"></i>感情趋势</h4>
                                    <p id="week-trend-love" class="text-xs text-gray-600"></p>
                                </div>
                                <div class="bg-white rounded-xl p-4 border border-sky-100">
                                    <h4 class="font-medium text-sm mb-1 flex items-center text-sky-700"><i class="fa fa-briefcase text-sky-500 mr-2"></i>事业趋势</h4>
                                    <p id="week-trend-career" class="text-xs text-gray-600"></p>
                                </div>
                                <div class="bg-white rounded-xl p-4 border border-emerald-100">
                                    <h4 class="font-medium text-sm mb-1 flex items-center text-emerald-700"><i class="fa fa-leaf text-emerald-500 mr-2"></i>健康趋势</h4>
                                    <p id="week-trend-health" class="text-xs text-gray-600"></p>
                                </div>
                            </div>
                            <div class="bg-white rounded-xl p-4 border border-purple-100">
                                <h4 class="font-medium text-sm mb-2 flex items-center text-purple-700"><i class="fa fa-bell text-purple-500 mr-2"></i>关键时间节点</h4>
                                <ul id="week-keydates" class="list-disc list-inside text-xs text-gray-600 space-y-1"></ul>
                            </div>
                        </div>

                        <!-- 月运：星象与策略 -->
                        <div id="monthly-section" class="mt-4 space-y-3 hidden">
                            <div class="bg-white rounded-xl p-4 border border-orange-100">
                                <h4 class="font-medium text-sm mb-1 flex items-center text-orange-700"><i class="fa fa-moon-o text-orange-500 mr-2"></i>当月星象影响</h4>
                                <p id="month-astro" class="text-xs text-gray-600"></p>
                            </div>
                            <div class="bg-white rounded-xl p-4 border border-teal-100">
                                <h4 class="font-medium text-sm mb-1 flex items-center text-teal-700"><i class="fa fa-compass text-teal-500 mr-2"></i>应对策略</h4>
                                <ul id="month-strategies" class="list-disc list-inside text-xs text-gray-600 space-y-1"></ul>
                            </div>
                        </div>

                        <!-- 年运：宏观指引 -->
                        <div id="yearly-section" class="mt-4 space-y-3 hidden">
                            <div class="bg-white rounded-xl p-4 border border-amber-200">
                                <h4 class="font-medium text-sm mb-1 flex items-center text-amber-800"><i class="fa fa-sun-o text-amber-500 mr-2"></i>年度宏观指引</h4>
                                <p id="year-guidance" class="text-xs text-gray-600"></p>
                            </div>
                            <div class="bg-white rounded-xl p-4 border border-indigo-100">
                                <h4 class="font-medium text-sm mb-1 flex items-center text-indigo-700"><i class="fa fa-flag-checkered text-indigo-500 mr-2"></i>年度重点</h4>
                                <ul id="year-focus" class="list-disc list-inside text-xs text-gray-600 space-y-1"></ul>
                            </div>
                        </div>

                        <!-- 星象解读：行星相位与逆行影响 -->
                        <div id="astro-section" class="mt-4 space-y-3 hidden">
                            <div class="bg-white rounded-xl p-4 border border-purple-100">
                                <h4 class="font-medium text-sm mb-1 flex items-center text-purple-700"><i class="fa fa-mars text-purple-500 mr-2"></i>行星相位</h4>
                                <ul id="astro-aspects" class="list-disc list-inside text-xs text-gray-600 space-y-1"></ul>
                            </div>
                            <div class="bg-white rounded-xl p-4 border border-rose-100">
                                <h4 class="font-medium text-sm mb-1 flex items-center text-rose-700"><i class="fa fa-retweet text-rose-500 mr-2"></i>逆行影响</h4>
                                <p id="retrograde-impact" class="text-xs text-gray-600 mb-2"></p>
                                <ul id="retrograde-tips" class="list-disc list-inside text-xs text-gray-600 space-y-1"></ul>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="text-center mt-8 mb-4">
                    <div class="inline-flex items-center space-x-2 text-gray-400 text-xs">
                        <div class="w-2 h-2 rounded-full bg-gradient-to-r from-amber-400 to-orange-400"></div>
                        <span>每日都有新发现</span>
                        <div class="w-2 h-2 rounded-full bg-gradient-to-r from-orange-400 to-amber-400"></div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 我的 Tab -->
        <div id="profile-tab" class="tab-content hidden">
            
            <div class="container mx-auto px-4 py-5 relative z-10">
                <!-- 页面标题 -->
                <div class="text-center mb-6">
                    <h1 class="text-2xl font-bold text-gray-800 mb-2">个人中心</h1>
                    <p class="text-gray-600 text-sm">管理你的账户和个性化设置</p>
                </div>
                
                <!-- 合并卡片：游客信息 + 我的星座人设 -->
                <div class="bg-gradient-to-br from-primary via-purple-500 to-secondary rounded-2xl shadow-xl p-6 text-white mb-6 relative overflow-hidden">
                    <div class="absolute top-0 right-0 w-32 h-32 bg-white/10 rounded-full -mr-16 -mt-16"></div>
                    <div class="absolute bottom-0 left-0 w-24 h-24 bg-white/10 rounded-full -ml-12 -mb-12"></div>
                    <div class="absolute top-1/2 left-1/2 w-16 h-16 bg-white/5 rounded-full transform -translate-x-1/2 -translate-y-1/2"></div>
                    <div class="absolute top-4 left-4 w-8 h-8 bg-white/5 rounded-full"></div>
                    <div class="absolute bottom-4 right-4 w-6 h-6 bg-white/5 rounded-full"></div>
                    <div class="relative z-10">
                        <div class="flex items-center mb-5">
                            <div class="w-16 h-16 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center mr-4 border-2 border-white/30 shadow-lg">
                                <i class="fa fa-user text-white text-2xl"></i>
                            </div>
                            <div class="flex-1">
                                <h3 class="font-bold text-lg mb-1">我的星座人设</h3>
                                <p class="text-white/80 text-sm">设置你的专属星座标签，获取个性化内容</p>
                            </div>
                        </div>
                        <div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
                            <div class="bg-white/15 backdrop-blur-sm rounded-xl p-3 border border-white/20">
                                <label class="text-[11px] text-white/80">我的星座</label>
                                <select id="persona-zodiac" class="mt-1 w-full bg-white/90 text-gray-800 border border-white/30 rounded-xl px-3 py-2 text-sm"></select>
                                <div class="mt-2 text-[12px] text-white/80">当前星座：<span id="profile-zodiac-status" class="font-semibold">未设置</span></div>
                            </div>
                            <div class="bg-white/15 backdrop-blur-sm rounded-xl p-3 border border-white/20">
                                <label class="text-[11px] text-white/80">个性化标签（可多选）</label>
                                <div id="persona-tags" class="mt-1 flex flex-wrap gap-2">
                                    <button data-tag="职场新人" class="tag-btn px-3 py-1.5 text-xs rounded-full border border-white/40 bg-white/20 text-white hover:border-white hover:bg-white/30 transition">职场新人</button>
                                    <button data-tag="考研党" class="tag-btn px-3 py-1.5 text-xs rounded-full border border-white/40 bg-white/20 text-white hover:border-white hover:bg-white/30 transition">考研党</button>
                                    <button data-tag="旅行爱好者" class="tag-btn px-3 py-1.5 text-xs rounded-full border border-white/40 bg-white/20 text-white hover:border-white hover:bg-white/30 transition">旅行爱好者</button>
                                    <button data-tag="猫控" class="tag-btn px-3 py-1.5 text-xs rounded-full border border-white/40 bg-white/20 text-white hover:border-white hover:bg-white/30 transition">猫控</button>
                                </div>
                            </div>
                        </div>
                        <div class="mt-3 flex items-center justify-between">
                            <div class="text-xs text-white/80">当前人设：<span id="persona-summary" class="text-white">未设置</span></div>
                            <button id="save-persona" class="bg-white/20 backdrop-blur-sm px-4 py-2 rounded-lg text-sm font-medium hover:bg-white/30 transition-all duration-300 border border-white/30 shadow-lg">保存</button>
                        </div>
                    </div>
                </div>
                
                <!-- 功能菜单 - 增强背景和视觉效果 -->
                <div class="space-y-4 mb-6">
                    
                    <!-- 我的测试 -->
                    <div class="bg-gradient-to-br from-white to-blue-50/50 rounded-2xl shadow-lg p-5 border border-blue-100/50 backdrop-blur-sm">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 rounded-full bg-gradient-to-br from-primary/20 to-blue-500/30 flex items-center justify-center mr-3 shadow-md">
                                <i class="fa fa-clipboard-list text-primary text-lg"></i>
                            </div>
                            <h3 class="text-base font-semibold text-gray-800">我的测试</h3>
                        </div>
                        <div class="space-y-3">
                            <div class="flex justify-between items-center p-3 rounded-xl hover:bg-blue-50/50 transition-all duration-300 cursor-pointer group bg-white/50" onclick="window.location.href='test-history.html'">
                                <div class="flex items-center">
                                    <div class="w-8 h-8 rounded-full bg-gradient-to-br from-blue-100 to-blue-200 flex items-center justify-center mr-3 group-hover:from-blue-200 group-hover:to-blue-300 transition-all duration-300 shadow-sm">
                                        <i class="fa fa-history text-blue-600 text-sm"></i>
                                    </div>
                                    <span class="text-sm font-medium text-gray-700">测试历史</span>
                                </div>
                                <div class="flex items-center">
                                    <span class="text-xs text-gray-400 mr-2">查看记录</span>
                                    <i class="fa fa-angle-right text-gray-400 group-hover:text-primary transition-colors"></i>
                                </div>
                            </div>
                            <div class="flex justify-between items-center p-3 rounded-xl hover:bg-pink-50/50 transition-all duration-300 cursor-pointer group bg-white/50">
                                <div class="flex items-center">
                                    <div class="w-8 h-8 rounded-full bg-gradient-to-br from-pink-100 to-pink-200 flex items-center justify-center mr-3 group-hover:from-pink-200 group-hover:to-pink-300 transition-all duration-300 shadow-sm">
                                        <i class="fa fa-bookmark-o text-pink-600 text-sm"></i>
                                    </div>
                                    <span class="text-sm font-medium text-gray-700">收藏的小知识/小技巧</span>
                                </div>
                                <div class="flex items-center">
                                    <span class="text-xs text-gray-400 mr-2">管理收藏</span>
                                    <i class="fa fa-angle-right text-gray-400 group-hover:text-primary transition-colors"></i>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 系统设置 -->
                    <div class="bg-gradient-to-br from-white to-purple-50/50 rounded-2xl shadow-lg p-5 border border-purple-100/50 backdrop-blur-sm">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 rounded-full bg-gradient-to-br from-secondary/20 to-purple-500/30 flex items-center justify-center mr-3 shadow-md">
                                <i class="fa fa-cog text-secondary text-lg"></i>
                            </div>
                            <h3 class="text-base font-semibold text-gray-800">系统设置</h3>
                        </div>
                        <div class="space-y-3">
                            <div class="p-3 rounded-xl hover:bg-green-50/50 transition-all duration-300 cursor-pointer group border border-green-100/50 hover:border-green-300/50 bg-white/50 backdrop-blur-sm">
                                <div class="flex items-center mb-2">
                                    <div class="w-6 h-6 rounded-full bg-gradient-to-br from-green-100 to-green-200 flex items-center justify-center mr-2 group-hover:from-green-200 group-hover:to-green-300 transition-all duration-300 shadow-sm">
                                        <i class="fa fa-user-o text-green-600 text-xs"></i>
                                    </div>
                                    <span class="text-sm font-medium text-gray-700">个人资料</span>
                                </div>
                                <p class="text-xs text-gray-500">管理账户信息</p>
                            </div>
                            <div class="p-3 rounded-xl hover:bg-blue-50/50 transition-all duration-300 cursor-pointer group border border-blue-100/50 hover:border-blue-300/50 bg-white/50 backdrop-blur-sm">
                                <div class="flex items-center mb-2">
                                    <div class="w-6 h-6 rounded-full bg-gradient-to-br from-blue-100 to-blue-200 flex items-center justify-center mr-2 group-hover:from-blue-200 group-hover:to-blue-300 transition-all duration-300 shadow-sm">
                                        <i class="fa fa-bell-o text-blue-600 text-xs"></i>
                                    </div>
                                    <span class="text-sm font-medium text-gray-700">通知设置</span>
                                </div>
                                <p class="text-xs text-gray-500">自定义提醒</p>
                            </div>
                            <div class="p-3 rounded-xl hover:bg-purple-50/50 transition-all duration-300 cursor-pointer group border border-purple-100/50 hover:border-purple-300/50 bg-white/50 backdrop-blur-sm">
                                <div class="flex items-center mb-2">
                                    <div class="w-6 h-6 rounded-full bg-gradient-to-br from-purple-100 to-purple-200 flex items-center justify-center mr-2 group-hover:from-purple-200 group-hover:to-purple-300 transition-all duration-300 shadow-sm">
                                        <i class="fa fa-question-circle-o text-purple-600 text-xs"></i>
                                    </div>
                                    <span class="text-sm font-medium text-gray-700">帮助中心</span>
                                </div>
                                <p class="text-xs text-gray-500">获取支持</p>
                            </div>
                            <div class="p-3 rounded-xl hover:bg-orange-50/50 transition-all duration-300 cursor-pointer group border border-orange-100/50 hover:border-orange-300/50 bg-white/50 backdrop-blur-sm">
                                <div class="flex items-center mb-2">
                                    <div class="w-6 h-6 rounded-full bg-gradient-to-br from-orange-100 to-orange-200 flex items-center justify-center mr-2 group-hover:from-orange-200 group-hover:to-orange-300 transition-all duration-300 shadow-sm">
                                        <i class="fa fa-sliders text-orange-600 text-xs"></i>
                                    </div>
                                    <span class="text-sm font-medium text-gray-700">通用设置</span>
                                </div>
                                <p class="text-xs text-gray-500">应用偏好</p>
                            </div>

                            <div id="open-goods-modal" class="p-3 rounded-xl hover:bg-amber-50/50 transition-all duration-300 cursor-pointer group border border-amber-100/50 hover:border-amber-300/50 bg-white/50 backdrop-blur-sm">
                                <div class="flex items-center mb-2">
                                    <div class="w-6 h-6 rounded-full bg-gradient-to-br from-amber-100 to-amber-200 flex items-center justify-center mr-2 group-hover:from-amber-200 group-hover:to-amber-300 transition-all duration-300 shadow-sm">
                                        <i class="fa fa-gift text-amber-600 text-xs"></i>
                                    </div>
                                    <span class="text-sm font-medium text-gray-700">星座好物推荐</span>
                                </div>
                                <p class="text-xs text-gray-500">结合你的星座偏好推荐实用好物</p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- 关于信息 - 增强背景设计 -->
                <div class="bg-gradient-to-br from-white via-pink-50/30 to-purple-50/30 rounded-2xl p-5 text-center border border-pink-200/50 shadow-lg backdrop-blur-sm">
                    <div class="w-12 h-12 rounded-full bg-gradient-to-br from-primary/20 to-pink-500/30 flex items-center justify-center mx-auto mb-3 shadow-md">
                        <i class="fa fa-heart text-primary text-xl"></i>
                    </div>
                    <h4 class="text-sm font-semibold text-gray-700 mb-1">星格 v1.0.0</h4>
                    <p class="text-gray-500 text-xs">探索你的人格与运势</p>
                    <div class="flex justify-center items-center mt-3 space-x-4 text-xs text-gray-400">
                        <span class="flex items-center">
                            <i class="fa fa-users mr-1"></i>
                            100万+ 用户
                        </span>
                        <span class="flex items-center">
                            <i class="fa fa-star mr-1"></i>
                            4.8 评分
                        </span>
                    </div>
                </div>
                
                <!-- 页面装饰元素 -->
                <div class="text-center mt-8 mb-4">
                    <div class="inline-flex items-center space-x-2 text-gray-400 text-xs">
                        <div class="w-2 h-2 rounded-full bg-gradient-to-r from-primary to-secondary"></div>
                        <span>个性化你的体验</span>
                        <div class="w-2 h-2 rounded-full bg-gradient-to-r from-secondary to-primary"></div>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <!-- 底部Tab导航 -->
    <footer class="fixed bottom-0 left-0 right-0 bg-white shadow-[0_-2px_10px_rgba(0,0,0,0.05)] z-30">
        <div class="container mx-auto">
            <div class="flex justify-around">
                <button class="tab-button tab-active flex flex-col items-center justify-center py-3 px-4 w-full" data-tab="test-tab">
                    <i class="fa fa-list-alt text-lg"></i>
                    <span class="text-xs mt-1">测试</span>
                </button>
                <button class="tab-button flex flex-col items-center justify-center py-3 px-4 w-full" data-tab="fortune-tab">
                    <i class="fa fa-moon-o text-lg"></i>
                    <span class="text-xs mt-1">运势</span>
                </button>
                <button class="tab-button flex flex-col items-center justify-center py-3 px-4 w-full" data-tab="profile-tab">
                    <i class="fa fa-user-o text-lg"></i>
                    <span class="text-xs mt-1">我的</span>
                </button>
            </div>
        </div>
    </footer>

    <!-- 我的页：底部模态 - 星座好物推荐列表 -->
    <div id="goods-bottom-sheet" class="fixed inset-0 bg-black/40 z-50 hidden">
        <div id="goods-bottom-sheet-panel" class="absolute bottom-0 left-0 right-0 bg-white rounded-t-3xl p-5 shadow-2xl transform translate-y-full transition-transform duration-300 will-change-transform">
            <div class="flex items-center justify-between mb-3">
                <div class="text-base font-semibold text-gray-800">星座好物推荐</div>
                <button id="close-goods-modal" class="w-8 h-8 rounded-full bg-gray-100 flex items-center justify-center hover:bg-gray-200"><i class="fa fa-times text-gray-600"></i></button>
            </div>
            <div id="goods-modal-list" class="space-y-3">
                <!-- 单条示例，进入时按星座填充 -->
            </div>
        </div>
    </div>

    <!-- 全局：底部弹出 - 星座选择器（不受任何 Tab hidden 影响） -->
    <div id="zodiac-bottom-sheet" class="fixed inset-0 bg-black/40 z-50 hidden">
        <div id="zodiac-bottom-sheet-panel" class="absolute bottom-0 left-0 right-0 bg-white rounded-t-3xl p-5 shadow-2xl transform translate-y-full transition-transform duration-300 will-change-transform">
            <div class="flex items-center justify-between mb-4">
                <div class="text-base font-semibold text-gray-800">选择星座</div>
                <button id="close-zodiac-picker" class="w-8 h-8 rounded-full bg-gray-100 flex items-center justify-center hover:bg-gray-200"><i class="fa fa-times text-gray-600"></i></button>
            </div>
            <div class="grid grid-cols-3 gap-3">
                <button data-zodiac="aries" class="zodiac-btn px-3 py-3 rounded-2xl border text-[14px] flex flex-col items-center gap-1 bg-gradient-to-b from-orange-50 to-amber-100 border-amber-200 text-amber-700 hover:shadow">
                    <span class="w-11 h-11 rounded-2xl overflow-hidden shadow-sm"><img src="assets/zodiac/aries.svg" alt="白羊座" class="w-full h-full object-cover"/></span>
                    <span class="text-[13px] font-semibold">白羊座</span>
                    <span class="text-[12px] text-gray-500">3.21-4.19</span>
                </button>
                <button data-zodiac="taurus" class="zodiac-btn px-3 py-3 rounded-2xl border text-[14px] flex flex-col items-center gap-1 bg-gradient-to-b from-emerald-50 to-green-100 border-emerald-200 text-emerald-700 hover:shadow">
                    <span class="w-11 h-11 rounded-2xl overflow-hidden shadow-sm"><img src="assets/zodiac/taurus.svg" alt="金牛座" class="w-full h-full object-cover"/></span>
                    <span class="text-[13px] font-semibold">金牛座</span>
                    <span class="text-[12px] text-gray-500">4.20-5.20</span>
                </button>
                <button data-zodiac="gemini" class="zodiac-btn px-3 py-3 rounded-2xl border text-[14px] flex flex-col items-center gap-1 bg-gradient-to-b from-violet-50 to-purple-100 border-violet-200 text-violet-700 hover:shadow">
                    <span class="w-11 h-11 rounded-2xl overflow-hidden shadow-sm"><img src="assets/zodiac/gemini.svg" alt="双子座" class="w-full h-full object-cover"/></span>
                    <span class="text-[13px] font-semibold">双子座</span>
                    <span class="text-[12px] text-gray-500">5.21-6.21</span>
                </button>
                <button data-zodiac="cancer" class="zodiac-btn px-3 py-3 rounded-2xl border text-[14px] flex flex-col items-center gap-1 bg-gradient-to-b from-sky-50 to-blue-100 border-sky-200 text-sky-700 hover:shadow">
                    <span class="w-11 h-11 rounded-2xl overflow-hidden shadow-sm"><img src="assets/zodiac/cancer.svg" alt="巨蟹座" class="w-full h-full object-cover"/></span>
                    <span class="text-[13px] font-semibold">巨蟹座</span>
                    <span class="text-[12px] text-gray-500">6.22-7.22</span>
                </button>
                <button data-zodiac="leo" class="zodiac-btn px-3 py-3 rounded-2xl border text-[14px] flex flex-col items-center gap-1 bg-gradient-to-b from-orange-50 to-amber-100 border-orange-200 text-orange-700 hover:shadow">
                    <span class="w-11 h-11 rounded-2xl overflow-hidden shadow-sm"><img src="assets/zodiac/leo.svg" alt="狮子座" class="w-full h-full object-cover"/></span>
                    <span class="text-[13px] font-semibold">狮子座</span>
                    <span class="text-[12px] text-gray-500">7.23-8.22</span>
                </button>
                <button data-zodiac="virgo" class="zodiac-btn px-3 py-3 rounded-2xl border text-[14px] flex flex-col items-center gap-1 bg-gradient-to-b from-stone-50 to-stone-100 border-stone-200 text-stone-700 hover:shadow">
                    <span class="w-11 h-11 rounded-2xl overflow-hidden shadow-sm"><img src="assets/zodiac/virgo.svg" alt="处女座" class="w-full h-full object-cover"/></span>
                    <span class="text-[13px] font-semibold">处女座</span>
                    <span class="text-[12px] text-gray-500">8.23-9.22</span>
                </button>
                <button data-zodiac="libra" class="zodiac-btn px-3 py-3 rounded-2xl border text-[14px] flex flex-col items-center gap-1 bg-gradient-to-b from-pink-50 to-rose-100 border-pink-200 text-pink-700 hover:shadow">
                    <span class="w-11 h-11 rounded-2xl overflow-hidden shadow-sm"><img src="assets/zodiac/libra.svg" alt="天秤座" class="w-full h-full object-cover"/></span>
                    <span class="text-[13px] font-semibold">天秤座</span>
                    <span class="text-[12px] text-gray-500">9.23-10.23</span>
                </button>
                <button data-zodiac="scorpio" class="zodiac-btn px-3 py-3 rounded-2xl border text-[14px] flex flex-col items-center gap-1 bg-gradient-to-b from-red-50 to-rose-100 border-red-200 text-red-700 hover:shadow">
                    <span class="w-11 h-11 rounded-2xl overflow-hidden shadow-sm"><img src="assets/zodiac/scorpio.svg" alt="天蝎座" class="w-full h-full object-cover"/></span>
                    <span class="text-[13px] font-semibold">天蝎座</span>
                    <span class="text-[12px] text-gray-500">10.24-11.22</span>
                </button>
                <button data-zodiac="sagittarius" class="zodiac-btn px-3 py-3 rounded-2xl border text-[14px] flex flex-col items-center gap-1 bg-gradient-to-b from-yellow-50 to-amber-100 border-yellow-200 text-yellow-700 hover:shadow">
                    <span class="w-11 h-11 rounded-2xl overflow-hidden shadow-sm"><img src="assets/zodiac/sagittarius.svg" alt="射手座" class="w-full h-full object-cover"/></span>
                    <span class="text-[13px] font-semibold">射手座</span>
                    <span class="text-[12px] text-gray-500">11.23-12.21</span>
                </button>
                <button data-zodiac="capricorn" class="zodiac-btn px-3 py-3 rounded-2xl border text-[14px] flex flex-col items-center gap-1 bg-gradient-to-b from-amber-50 to-amber-100 border-amber-200 text-amber-800 hover:shadow">
                    <span class="w-11 h-11 rounded-2xl overflow-hidden shadow-sm"><img src="assets/zodiac/capricorn.svg" alt="摩羯座" class="w-full h-full object-cover"/></span>
                    <span class="text-[13px] font-semibold">摩羯座</span>
                    <span class="text-[12px] text-gray-500">12.22-1.19</span>
                </button>
                <button data-zodiac="aquarius" class="zodiac-btn px-3 py-3 rounded-2xl border text-[14px] flex flex-col items-center gap-1 bg-gradient-to-b from-indigo-50 to-blue-100 border-indigo-200 text-indigo-700 hover:shadow">
                    <span class="w-11 h-11 rounded-2xl overflow-hidden shadow-sm"><img src="assets/zodiac/aquarius.svg" alt="水瓶座" class="w-full h-full object-cover"/></span>
                    <span class="text-[13px] font-semibold">水瓶座</span>
                    <span class="text-[12px] text-gray-500">1.20-2.18</span>
                </button>
                <button data-zodiac="pisces" class="zodiac-btn px-3 py-3 rounded-2xl border text-[14px] flex flex-col items-center gap-1 bg-gradient-to-b from-teal-50 to-cyan-100 border-teal-200 text-teal-700 hover:shadow">
                    <span class="w-11 h-11 rounded-2xl overflow-hidden shadow-sm"><img src="assets/zodiac/pisces.svg" alt="双鱼座" class="w-full h-full object-cover"/></span>
                    <span class="text-[13px] font-semibold">双鱼座</span>
                    <span class="text-[12px] text-gray-500">2.19-3.20</span>
                </button>
            </div>
        </div>
    </div>

    <script>
        // Tab切换功能
        document.addEventListener('DOMContentLoaded', function() {
            const tabButtons = document.querySelectorAll('.tab-button');
            const tabContents = document.querySelectorAll('.tab-content');
            
            tabButtons.forEach(button => {
                button.addEventListener('click', () => {
                    // 移除所有活跃状态
                    tabButtons.forEach(btn => btn.classList.remove('tab-active'));
                    tabContents.forEach(content => content.classList.add('hidden'));
                    
                    // 添加当前活跃状态
                    button.classList.add('tab-active');
                    const tabId = button.getAttribute('data-tab');
                    document.getElementById(tabId).classList.remove('hidden');
                });
            });
            
            // 添加卡片悬停动画效果
            const cards = document.querySelectorAll('.card-hover');
            cards.forEach(card => {
                card.addEventListener('mouseenter', () => {
                    card.classList.add('shadow-lg', '-translate-y-1');
                });
                card.addEventListener('mouseleave', () => {
                    card.classList.remove('shadow-lg', '-translate-y-1');
                });
            });

            // 更新首页运势卡片数据的函数
            function updateHomeFortuneCard(zodiacId, zodiacName) {
                const data = getMockFortuneData(zodiacId, 'today');
                
                // 更新星座名称
                const zodiacNameEl = document.getElementById('home-zodiac-name');
                if (zodiacNameEl) {
                    zodiacNameEl.textContent = zodiacName;
                }
                
                // 更新日期
                const dateEl = document.getElementById('home-fortune-date');
                if (dateEl) {
                    const today = new Date();
                    const dateStr = `${today.getFullYear()}年${today.getMonth() + 1}月${today.getDate()}日`;
                    dateEl.textContent = dateStr;
                }
                
                // 更新运势状态
                const statusEl = document.getElementById('home-fortune-status');
                if (statusEl) {
                    const overall = data.ratings.overall;
                    if (overall >= 4) {
                        statusEl.textContent = '运势佳';
                        statusEl.className = 'ml-auto bg-gradient-to-r from-green-100 to-green-200 text-green-700 text-xs px-2 py-1 rounded-full border border-green-200/50';
                    } else if (overall >= 3) {
                        statusEl.textContent = '运势一般';
                        statusEl.className = 'ml-auto bg-gradient-to-r from-yellow-100 to-yellow-200 text-yellow-700 text-xs px-2 py-1 rounded-full border border-yellow-200/50';
                    } else {
                        statusEl.textContent = '运势不佳';
                        statusEl.className = 'ml-auto bg-gradient-to-r from-red-100 to-red-200 text-red-700 text-xs px-2 py-1 rounded-full border border-red-200/50';
                    }
                }
                
                // 更新各项分数
                const loveScoreEl = document.getElementById('home-love-score');
                if (loveScoreEl) {
                    loveScoreEl.textContent = `${data.ratings.love * 20}分`;
                }
                
                const careerScoreEl = document.getElementById('home-career-score');
                if (careerScoreEl) {
                    careerScoreEl.textContent = `${data.ratings.career * 20}分`;
                }
                
                const wealthScoreEl = document.getElementById('home-wealth-score');
                if (wealthScoreEl) {
                    wealthScoreEl.textContent = `${data.ratings.wealth * 20}分`;
                }
                
                // 更新运势描述
                const descriptionEl = document.getElementById('home-fortune-description');
                if (descriptionEl) {
                    descriptionEl.textContent = data.summary;
                }
            }

            // 今日运势查看全部按钮
            const viewAllFortuneBtn = document.getElementById('view-all-fortune');
            if (viewAllFortuneBtn) {
                viewAllFortuneBtn.addEventListener('click', (e) => {
                    e.preventDefault();
                    
                    // 星座列表
                    const zodiacList = [
                        { id: 'aries', name: '白羊座' },
                        { id: 'taurus', name: '金牛座' },
                        { id: 'gemini', name: '双子座' },
                        { id: 'cancer', name: '巨蟹座' },
                        { id: 'leo', name: '狮子座' },
                        { id: 'virgo', name: '处女座' },
                        { id: 'libra', name: '天秤座' },
                        { id: 'scorpio', name: '天蝎座' },
                        { id: 'sagittarius', name: '射手座' },
                        { id: 'capricorn', name: '摩羯座' },
                        { id: 'aquarius', name: '水瓶座' },
                        { id: 'pisces', name: '双鱼座' }
                    ];
                    
                    // 随机选择一个星座
                    const randomIndex = Math.floor(Math.random() * zodiacList.length);
                    const randomZodiac = zodiacList[randomIndex];
                    
                    // 更新首页运势卡片数据
                    updateHomeFortuneCard(randomZodiac.id, randomZodiac.name);
                });
            }

            // 推荐内容数据
            const knowledgeData = {
                zodiac: {
                    title: '星座相关小知识',
                    items: [
                        '火象星座（白羊、狮子、射手）行动力强，适合主动出击。',
                        '土象星座（金牛、处女、摩羯）务实稳重，重视长期积累。',
                        '风象星座（双子、天秤、水瓶）善沟通，适合信息与社交场景。',
                        '水象星座（巨蟹、天蝎、双鱼）情感细腻，重感受与直觉。',
                        '上升星座代表对外气质与第一印象。'
                    ]
                },
                personality: {
                    title: '人格相关小知识',
                    items: [
                        'MBTI不是能力测试，而是偏好模型，重在理解差异。',
                        '外向并非社恐的反义，内外向都可能社交自如。',
                        '判断型偏好规划和确定性，知觉型偏好弹性与探索。',
                        '思考型决策偏逻辑一致，情感型偏价值与人际影响。',
                        '认知功能像"使用习惯"，会随环境发展而变化。'
                    ]
                },
                love: {
                    title: '感情相关小知识',
                    items: [
                        '今日份"渣男"典型行为：热烈追求后迅速冷淡，出现明显情感落差。',
                        '识别"渣女"常见套路：暧昧不清、反复横跳，回避明确承诺。',
                        '情感边界小技巧：对超出舒适区的请求练习礼貌拒绝与替代方案。',
                        '冷暴力识别：长时间无回应、回避沟通、以沉默惩罚对方。',
                        'PUA预警：贬低你的价值、制造自我怀疑，以控制关系主导权。',
                        '三观不合信号：价值冲突高频出现且难以通过沟通达成共识。',
                        '约会"红旗"提示：临时放鸽子、隐瞒重要信息、只在深夜联系。',
                        '高质量沟通三步：描述事实—表达感受—提出具体可执行请求。',
                        '安全感提升法：自我稳定+清晰边界+稳定回应，而非监控与控制。',
                        '过度付出的警示：失衡的长期投入会引发内耗与怨气，需及时调整。'
                    ]
                }
            };

            // 防抖函数
            function debounce(func, wait) {
                let timeout;
                return function executedFunction(...args) {
                    const later = () => {
                        clearTimeout(timeout);
                        func(...args);
                    };
                    clearTimeout(timeout);
                    timeout = setTimeout(later, wait);
                };
            }

            // 记录已显示的推荐内容，避免重复
            let shownRecommendations = new Set();
            let currentRecommendationIndex = -1;
            
            // 更新推荐内容
            function updateRecommendations() {
                console.log('updateRecommendations函数被调用'); // 调试信息
                
                if (!recommendationData || recommendationData.length === 0) {
                    console.error('推荐数据未定义或为空');
                    return;
                }
                
                // 智能推荐逻辑：避免重复显示
                let randomIndex;
                let attempts = 0;
                const maxAttempts = recommendationData.length * 2; // 最多尝试次数
                
                do {
                    randomIndex = Math.floor(Math.random() * recommendationData.length);
                    attempts++;
                } while (shownRecommendations.has(randomIndex) && attempts < maxAttempts);
                
                // 如果所有内容都已显示过，重置记录
                if (attempts >= maxAttempts) {
                    shownRecommendations.clear();
                    randomIndex = Math.floor(Math.random() * recommendationData.length);
                }
                
                // 记录当前显示的内容
                shownRecommendations.add(randomIndex);
                currentRecommendationIndex = randomIndex;
                const randomData = recommendationData[randomIndex];
                
                console.log('更新推荐内容:', randomData.title, randomData.items); // 调试信息
                
                // 获取内容容器
                let contentContainer = document.querySelector('.bg-white\\/50.rounded-xl.p-4');
                if (!contentContainer) {
                    // 备选选择器
                    contentContainer = document.querySelector('[id="recommend-content"]').parentElement;
                }
                if (!contentContainer) {
                    console.error('找不到内容容器');
                    return;
                }
                
                // 添加更流畅的淡出效果
                contentContainer.style.transition = 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)';
                contentContainer.style.opacity = '0.3';
                contentContainer.style.transform = 'translateY(15px) scale(0.98)';
                
                // 延迟更新内容，让动画更自然
                setTimeout(() => {
                    // 更新标题
                    const titleEl = document.getElementById('recommend-title');
                    if (titleEl) {
                        titleEl.innerHTML = `<i class="fa ${randomData.icon} text-primary mr-2"></i>${randomData.title}`;
                        console.log('标题已更新:', randomData.title); // 调试信息
                    } else {
                        console.error('找不到标题元素');
                    }
                    
                    // 更新内容
                    const contentEl = document.getElementById('recommend-content');
                    if (contentEl) {
                        // 个性化偏置：若存在人设标签，在推荐顶部插入 1-2 条相关提示
                        let personaTips = [];
                        try {
                            const persona = JSON.parse(localStorage.getItem('persona') || 'null');
                            if (persona && Array.isArray(persona.tags)) {
                                if (persona.tags.includes('考研党') && randomData.title.includes('人格')) {
                                    personaTips.push('考研党时间管理：使用 25/5 番茄提升节奏感');
                                }
                                if (persona.tags.includes('职场新人') && randomData.title.includes('星座')) {
                                    personaTips.push('职场沟通：先复述对方要点再表达观点，减少误解');
                                }
                            }
                        } catch (e) { /* noop */ }
                        const personaHtml = personaTips.map((t, i)=>`<a href="#" class="block py-2 ${'border-b border-purple-100/30'} text-gray-700 hover:text-primary transition-all duration-200 hover:bg-purple-50/30 rounded px-2 -mx-2 transform translate-y-3 opacity-0" style="animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) ${i * 0.08}s forwards">${t}</a>`).join('');
                        contentEl.innerHTML = personaHtml + randomData.items.map((item, index) => {
                            const isLast = index === randomData.items.length - 1;
                            return `<a href="#" class="block py-2 ${!isLast ? 'border-b border-purple-100/30' : ''} text-gray-700 hover:text-primary transition-all duration-200 hover:bg-purple-50/30 rounded px-2 -mx-2 transform translate-y-3 opacity-0" style="animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) ${index * 0.08}s forwards">${item}</a>`;
                        }).join('');
                        console.log('内容已更新:', randomData.items); // 调试信息
                    } else {
                        console.error('找不到内容元素');
                    }
                    
                    // 恢复淡入效果，使用更平滑的动画
                    setTimeout(() => {
                        contentContainer.style.opacity = '1';
                        contentContainer.style.transform = 'translateY(0) scale(1)';
                    }, 50);
                }, 200);
            }

            // 推荐内容换一批按钮
            const refreshRecommendBtn = document.getElementById('refresh-recommendations');
            const refreshIcon = document.getElementById('refresh-icon');
            const refreshText = document.getElementById('refresh-text');
            
            console.log('推荐按钮元素:', refreshRecommendBtn); // 调试信息
            
            if (refreshRecommendBtn) {
                console.log('推荐按钮事件监听器已绑定'); // 调试信息
                refreshRecommendBtn.addEventListener('click', (e) => {
                    e.preventDefault();
                    console.log('换一批按钮被点击'); // 调试信息
                    
                    // 防止重复点击
                    if (refreshRecommendBtn.disabled) {
                        console.log('按钮已禁用，忽略点击');
                        return;
                    }
                    
                    // 设置加载状态
                    refreshRecommendBtn.disabled = true;
                    refreshRecommendBtn.style.transform = 'scale(0.95)';
                    refreshRecommendBtn.style.background = 'linear-gradient(135deg, #8b5cf6, #a855f7)';
                    refreshRecommendBtn.style.color = 'white';
                    
                    if (refreshIcon) {
                        refreshIcon.className = 'fa fa-spinner fa-spin text-xs';
                        refreshIcon.style.animation = 'spin 1s linear infinite';
                    }
                    if (refreshText) refreshText.textContent = '刷新中...';
                    
                    console.log('开始更新推荐内容');
                    
                    // 添加按钮点击动画
                    setTimeout(() => {
                        refreshRecommendBtn.style.transform = 'scale(1)';
                    }, 100);
                    
                    // 执行更新
                    updateRecommendations();
                    
                    // 恢复按钮状态
                    setTimeout(() => {
                        refreshRecommendBtn.disabled = false;
                        refreshRecommendBtn.style.transform = 'scale(1)';
                        refreshRecommendBtn.style.background = '';
                        refreshRecommendBtn.style.color = '';
                        
                        if (refreshIcon) {
                            refreshIcon.className = 'fa fa-check text-xs';
                            refreshIcon.style.animation = '';
                        }
                        if (refreshText) refreshText.textContent = '已更新';
                        
                        // 短暂显示成功状态
                        setTimeout(() => {
                            if (refreshIcon) refreshIcon.className = 'fa fa-refresh text-xs';
                            if (refreshText) refreshText.textContent = '换一批';
                        }, 1000);
                        
                        console.log('按钮状态已恢复');
                    }, 600);
                });
                
                // 添加按钮悬停效果
                refreshRecommendBtn.addEventListener('mouseenter', () => {
                    if (!refreshRecommendBtn.disabled) {
                        refreshRecommendBtn.style.transform = 'scale(1.05)';
                        refreshRecommendBtn.style.boxShadow = '0 4px 12px rgba(139, 92, 246, 0.3)';
                    }
                });
                
                refreshRecommendBtn.addEventListener('mouseleave', () => {
                    if (!refreshRecommendBtn.disabled) {
                        refreshRecommendBtn.style.transform = 'scale(1)';
                        refreshRecommendBtn.style.boxShadow = '';
                    }
                });
            } else {
                console.error('找不到推荐按钮元素');
            }

            // 初始化小知识展示
            function initializeKnowledge() {
                // 填充三栏的一行简介
                const zodiacFirst = document.getElementById('rec-zodiac-line');
                const personalityFirst = document.getElementById('rec-personality-line');
                const loveFirst = document.getElementById('rec-love-line');
                const pickRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
                if (zodiacFirst) zodiacFirst.textContent = pickRandom(knowledgeData.zodiac.items);
                if (personalityFirst) personalityFirst.textContent = pickRandom(knowledgeData.personality.items);
                if (loveFirst) loveFirst.textContent = pickRandom(knowledgeData.love.items);

                // 绑定点击打开半屏模态
                const modal = document.getElementById('recommend-modal');
                const modalPanel = modal ? modal.querySelector('div') : null;
                const modalTitle = document.getElementById('recommend-modal-title');
                const modalContent = document.getElementById('recommend-modal-content');
                const closeBtn = document.getElementById('close-recommend-modal');

                function openModal(groupKey) {
                    const data = knowledgeData[groupKey];
                    if (!modal || !modalPanel || !modalTitle || !modalContent || !data) return;
                    modalTitle.textContent = data.title;
                    modalContent.innerHTML = data.items.map((txt, i) => `
                        <div class="p-3 rounded-lg border ${i%2===0 ? 'bg-gray-50' : 'bg-white'} text-sm text-gray-700">${i+1}. ${txt}</div>
                    `).join('');
                    modal.classList.remove('hidden');
                    requestAnimationFrame(() => modalPanel.classList.remove('translate-y-full'));
                }

                function closeModal() {
                    if (!modal || !modalPanel) return;
                    modalPanel.classList.add('translate-y-full');
                    setTimeout(() => modal.classList.add('hidden'), 300);
                }

                const recZodiac = document.getElementById('rec-zodiac');
                const recPersonality = document.getElementById('rec-personality');
                const recLove = document.getElementById('rec-love');
                if (recZodiac) recZodiac.addEventListener('click', () => openModal('zodiac'));
                if (recPersonality) recPersonality.addEventListener('click', () => openModal('personality'));
                if (recLove) recLove.addEventListener('click', () => openModal('love'));

                if (closeBtn) closeBtn.addEventListener('click', closeModal);
                if (modal) modal.addEventListener('click', (e) => { if (e.target === modal) closeModal(); });
            }

            // 调用初始化
            if (document.readyState === 'loading') {
                document.addEventListener('DOMContentLoaded', initializeKnowledge);
            } else {
                initializeKnowledge();
            }

            // 模态弹窗控制逻辑
            const personalityModal = document.getElementById('personality-modal');
            const zodiacModal = document.getElementById('zodiac-modal');
            const partnerModal = document.getElementById('partner-modal');
            const bottomSheet = document.getElementById('zodiac-bottom-sheet');
            const bottomSheetPanel = document.getElementById('zodiac-bottom-sheet-panel');
            const openZodiacPicker = document.getElementById('open-zodiac-picker');
            const closeZodiacPicker = document.getElementById('close-zodiac-picker');
            const personalityModule = document.getElementById('personality-module');
            const zodiacModule = document.getElementById('zodiac-module');
            const partnerModule = document.getElementById('partner-module');
            const closePersonalityModal = document.getElementById('close-personality-modal');
            const closeZodiacModal = document.getElementById('close-zodiac-modal');
            const closePartnerModal = document.getElementById('close-partner-modal');

            // 显示人格测试模态弹窗
            personalityModule.addEventListener('click', () => {
                personalityModal.classList.remove('hidden');
                // 延迟一帧后添加动画，确保元素已显示
                requestAnimationFrame(() => {
                    const modalContent = personalityModal.querySelector('div');
                    modalContent.classList.remove('translate-y-full');
                });
            });

            // 显示星座测试模态弹窗
            zodiacModule.addEventListener('click', () => {
                zodiacModal.classList.remove('hidden');
                // 延迟一帧后添加动画，确保元素已显示
                requestAnimationFrame(() => {
                    const modalContent = zodiacModal.querySelector('div');
                    modalContent.classList.remove('translate-y-full');
                });
            });

            // 显示伴侣测试模态弹窗
            if (partnerModule) {
                partnerModule.addEventListener('click', () => {
                    partnerModal.classList.remove('hidden');
                    // 延迟一帧后添加动画，确保元素已显示
                    requestAnimationFrame(() => {
                        const modalContent = partnerModal.querySelector('div');
                        modalContent.classList.remove('translate-y-full');
                    });
                });
            }

            // 打开底部星座选择器
            if (openZodiacPicker && bottomSheet && bottomSheetPanel) {
                openZodiacPicker.addEventListener('click', () => {
                    bottomSheet.classList.remove('hidden');
                    requestAnimationFrame(() => {
                        bottomSheetPanel.classList.remove('translate-y-full');
                    });
                });
            }

            // 关闭人格测试模态弹窗
            closePersonalityModal.addEventListener('click', () => {
                const modalContent = personalityModal.querySelector('div');
                modalContent.classList.add('translate-y-full');
                setTimeout(() => {
                    personalityModal.classList.add('hidden');
                }, 300);
            });

            // 关闭星座测试模态弹窗
            closeZodiacModal.addEventListener('click', () => {
                const modalContent = zodiacModal.querySelector('div');
                modalContent.classList.add('translate-y-full');
                setTimeout(() => {
                    zodiacModal.classList.add('hidden');
                }, 300);
            });

            // 关闭伴侣测试模态弹窗
            closePartnerModal.addEventListener('click', () => {
                const modalContent = partnerModal.querySelector('div');
                modalContent.classList.add('translate-y-full');
                setTimeout(() => {
                    partnerModal.classList.add('hidden');
                }, 300);
            });

            // 关闭底部星座选择器
            if (closeZodiacPicker && bottomSheet && bottomSheetPanel) {
                closeZodiacPicker.addEventListener('click', () => {
                    bottomSheetPanel.classList.add('translate-y-full');
                    setTimeout(() => {
                        bottomSheet.classList.add('hidden');
                    }, 300);
                });
            }

            // 点击模态弹窗背景关闭
            personalityModal.addEventListener('click', (e) => {
                if (e.target === personalityModal) {
                    const modalContent = personalityModal.querySelector('div');
                    modalContent.classList.add('translate-y-full');
                    setTimeout(() => {
                        personalityModal.classList.add('hidden');
                    }, 300);
                }
            });

            zodiacModal.addEventListener('click', (e) => {
                if (e.target === zodiacModal) {
                    const modalContent = zodiacModal.querySelector('div');
                    modalContent.classList.add('translate-y-full');
                    setTimeout(() => {
                        zodiacModal.classList.add('hidden');
                    }, 300);
                }
            });

            partnerModal.addEventListener('click', (e) => {
                if (e.target === partnerModal) {
                    const modalContent = partnerModal.querySelector('div');
                    modalContent.classList.add('translate-y-full');
                    setTimeout(() => {
                        partnerModal.classList.add('hidden');
                    }, 300);
                }
            });

            // 点击底部选择器背景关闭
            if (bottomSheet && bottomSheetPanel) {
                bottomSheet.addEventListener('click', (e) => {
                    if (e.target === bottomSheet) {
                        bottomSheetPanel.classList.add('translate-y-full');
                        setTimeout(() => {
                            bottomSheet.classList.add('hidden');
                        }, 300);
                    }
                });
            }

            // 星座选择与时间范围
            let selectedZodiac = null;
            let currentRange = 'today';
            // 填充日期（基于当前范围）
            const selectorDateEl = document.getElementById('selector-date');
            const fortuneDateEl = document.getElementById('fortune-date');
            const initialDateText = getRangeDisplayDate(currentRange);
            if (selectorDateEl) selectorDateEl.innerHTML = `<i class="fa fa-calendar-o mr-1"></i>${initialDateText}`;
            if (fortuneDateEl) fortuneDateEl.textContent = initialDateText;
            
            function selectZodiac(zodiacId, zodiacName) {
                // 移除所有星座按钮的选中状态
                const allZodiacBtns = document.querySelectorAll('.zodiac-btn');
                allZodiacBtns.forEach(btn => {
                    btn.classList.remove('ring-4', 'ring-primary/30', 'scale-105');
                    btn.style.transform = '';
                });
                
                // 为选中的星座按钮添加选中状态
                const selectedBtn = document.querySelector(`[data-zodiac="${zodiacId}"]`);
                if (selectedBtn) {
                    selectedBtn.classList.add('ring-4', 'ring-primary/30', 'scale-105');
                    selectedBtn.style.transform = 'scale(1.05)';
                    
                    // 添加选中动画效果
                    selectedBtn.style.animation = 'zodiacSelect 0.3s ease-out';
                }
                
                // 更新选中的星座
                selectedZodiac = zodiacId;
                
                // 更新运势详情标题在 updateFortuneData 中统一处理
                
                // 显示选中反馈
                showZodiacFeedback(zodiacName);
                
                // 更新运势数据（考虑当前范围）
                updateFortuneData(zodiacId, zodiacName, currentRange);

                // 更新触发器展示与关闭选择器
                const nameEl = document.getElementById('selected-zodiac-name');
                const rangeEl = document.getElementById('selected-zodiac-range');
                const avatarEl = document.getElementById('selected-zodiac-avatar');
                const imgEl = document.getElementById('selected-zodiac-img');
                const zodiacIdToImg = {
                    aries: 'assets/zodiac/aries.svg',
                    taurus: 'assets/zodiac/taurus.svg',
                    gemini: 'assets/zodiac/gemini.svg',
                    cancer: 'assets/zodiac/cancer.svg',
                    leo: 'assets/zodiac/leo.svg',
                    virgo: 'assets/zodiac/virgo.svg',
                    libra: 'assets/zodiac/libra.svg',
                    scorpio: 'assets/zodiac/scorpio.svg',
                    sagittarius: 'assets/zodiac/sagittarius.svg',
                    capricorn: 'assets/zodiac/capricorn.svg',
                    aquarius: 'assets/zodiac/aquarius.svg',
                    pisces: 'assets/zodiac/pisces.svg'
                };
                const zodiacIdToName = {
                    aries: '白羊座', taurus: '金牛座', gemini: '双子座', cancer: '巨蟹座',
                    leo: '狮子座', virgo: '处女座', libra: '天秤座', scorpio: '天蝎座',
                    sagittarius: '射手座', capricorn: '摩羯座', aquarius: '水瓶座', pisces: '双鱼座'
                };
                const zodiacIdToRange = {
                    aries: '3.21-4.19', taurus: '4.20-5.20', gemini: '5.21-6.21', cancer: '6.22-7.22',
                    leo: '7.23-8.22', virgo: '8.23-9.22', libra: '9.23-10.23', scorpio: '10.24-11.22',
                    sagittarius: '11.23-12.21', capricorn: '12.22-1.19', aquarius: '1.20-2.18', pisces: '2.19-3.20'
                };
                if (nameEl) nameEl.textContent = zodiacName || zodiacIdToName[zodiacId] || '';
                if (rangeEl) rangeEl.textContent = zodiacIdToRange[zodiacId] || '';
                if (imgEl && zodiacIdToImg[zodiacId]) imgEl.src = zodiacIdToImg[zodiacId];
                if (bottomSheet && bottomSheetPanel) {
                    bottomSheetPanel.classList.add('translate-y-full');
                    setTimeout(() => bottomSheet.classList.add('hidden'), 300);
                }
            }
            // 暴露到全局，供内联 onclick 调用
            window.selectZodiac = selectZodiac;
            
            function showZodiacFeedback(zodiacName) {
                // 创建或更新反馈提示
                let feedback = document.getElementById('zodiac-feedback');
                if (!feedback) {
                    feedback = document.createElement('div');
                    feedback.id = 'zodiac-feedback';
                    feedback.className = 'fixed top-20 left-1/2 transform -translate-x-1/2 bg-gradient-to-r from-primary to-secondary text-white px-4 py-2 rounded-full shadow-lg z-50';
                    document.body.appendChild(feedback);
                }
                
                feedback.innerHTML = `
                    <div class="flex items-center space-x-2">
                        <i class="fa fa-check-circle"></i>
                        <span>已选择 ${zodiacName}</span>
                    </div>
                `;
                
                feedback.style.display = 'block';
                
                // 3秒后自动隐藏
                setTimeout(() => {
                    feedback.style.display = 'none';
                }, 3000);
            }
            
            function updateFortuneData(zodiacId, zodiacName, range) {
                const data = getMockFortuneData(zodiacId, range);
                const titleElement = document.querySelector('#fortune-title');
                    if (titleElement) {
                    const rangeTextMap = { today: '今日', week: '本周', month: '本月', year: '今年' };
                    const rangeText = rangeTextMap[range] || '今日';
                    titleElement.textContent = `${zodiacName} ${rangeText}运势`;
                }
                renderStars('overall-stars', data.ratings.overall);
                renderStars('love-stars', data.ratings.love);
                renderStars('career-stars', data.ratings.career);
                renderStars('wealth-stars', data.ratings.wealth);

                const luckyColorEl = document.getElementById('lucky-color');
                const luckyNumberEl = document.getElementById('lucky-number');
                const luckyDirectionEl = document.getElementById('lucky-direction');
                if (luckyColorEl) luckyColorEl.innerHTML = `<i class="fa fa-paint-brush mr-1"></i>幸运色：${data.lucky.color}`;
                if (luckyNumberEl) luckyNumberEl.innerHTML = `<i class="fa fa-dice mr-1"></i>幸运数字：${data.lucky.number}`;
                if (luckyDirectionEl) luckyDirectionEl.innerHTML = `<i class="fa fa-compass mr-1"></i>幸运方位：${data.lucky.direction}`;


                // 切换显示不同范围的扩展信息
                const dailyExtra = document.getElementById('daily-extra');
                const weeklySection = document.getElementById('weekly-section');
                const monthlySection = document.getElementById('monthly-section');
                const yearlySection = document.getElementById('yearly-section');
                const astroSection = document.getElementById('astro-section');
                if (dailyExtra) dailyExtra.classList.add('hidden');
                if (weeklySection) weeklySection.classList.add('hidden');
                if (monthlySection) monthlySection.classList.add('hidden');
                if (yearlySection) yearlySection.classList.add('hidden');
                if (astroSection) astroSection.classList.add('hidden');

                if (range === 'today') {
                    if (dailyExtra) dailyExtra.classList.remove('hidden');
                    const luckyTimeEl = document.getElementById('lucky-time');
                    const doListEl = document.getElementById('do-list');
                    const dontListEl = document.getElementById('dont-list');
                    if (luckyTimeEl) luckyTimeEl.textContent = data.today.luckyTime || '';
                    if (doListEl) doListEl.innerHTML = (data.today.do || []).map(x => `<li>${x}</li>`).join('');
                    if (dontListEl) dontListEl.innerHTML = (data.today.dont || []).map(x => `<li>${x}</li>`).join('');
                } else if (range === 'week') {
                    if (weeklySection) weeklySection.classList.remove('hidden');
                    const wtLove = document.getElementById('week-trend-love');
                    const wtCareer = document.getElementById('week-trend-career');
                    const wtHealth = document.getElementById('week-trend-health');
                    const wkDates = document.getElementById('week-keydates');
                    if (wtLove) wtLove.textContent = data.week.trends.love || '';
                    if (wtCareer) wtCareer.textContent = data.week.trends.career || '';
                    if (wtHealth) wtHealth.textContent = data.week.trends.health || '';
                    if (wkDates) wkDates.innerHTML = (data.week.keyDates || []).map(x => `<li>${x}</li>`).join('');
                } else if (range === 'month') {
                    if (monthlySection) monthlySection.classList.remove('hidden');
                    const mAstro = document.getElementById('month-astro');
                    const mStrat = document.getElementById('month-strategies');
                    if (mAstro) mAstro.textContent = data.month.astro || '';
                    if (mStrat) mStrat.innerHTML = (data.month.strategies || []).map(x => `<li>${x}</li>`).join('');
                } else if (range === 'year') {
                    if (yearlySection) yearlySection.classList.remove('hidden');
                    const yGuide = document.getElementById('year-guidance');
                    const yFocus = document.getElementById('year-focus');
                    if (yGuide) yGuide.textContent = data.year.guidance || '';
                    if (yFocus) yFocus.innerHTML = (data.year.focus || []).map(x => `<li>${x}</li>`).join('');
                }

                // 星象解读：交由独立渲染函数
                renderAstroInsights(zodiacId, range, data);

                // 个性化解读（基于人设标签追加一段建议）
                try {
                    const persona = JSON.parse(localStorage.getItem('persona') || 'null');
                    const extraAdvice = [];
                    if (persona && Array.isArray(persona.tags)) {
                        if (persona.tags.includes('职场新人')) {
                            extraAdvice.push('职场新人：专注项目细节，远离办公室八卦，复盘能加分');
                        }
                        if (persona.tags.includes('考研党')) {
                            extraAdvice.push('考研党：利用专注高峰 9:00-11:00、15:00-17:00 进行高强度背诵');
                        }
                        if (persona.tags.includes('旅行爱好者')) {
                            extraAdvice.push('旅行：提前查看路况与天气，保留弹性与备选方案');
                        }
                    }
                    const dailyExtraEl = document.getElementById('daily-extra');
                    if (extraAdvice.length && dailyExtraEl && range === 'today') {
                        const box = document.createElement('div');
                        box.className = 'bg-white rounded-xl p-4 border border-primary/20';
                        box.innerHTML = `<h4 class="font-medium text-sm mb-1 flex items-center text-primary"><i class="fa fa-user mr-2"></i>个性化解读</h4><ul class="list-disc list-inside text-xs text-gray-600 space-y-1">${extraAdvice.map(x=>`<li>${x}</li>`).join('')}</ul>`;
                        dailyExtraEl.prepend(box);
                    }
                } catch (e) { /* noop */ }

                // 星座好物推荐（随选中星座变化）
                const goodsList = document.getElementById('goods-list');
                if (goodsList) {
                    const goods = pickGoodsByZodiac(zodiacId);
                    goodsList.innerHTML = goods.map((g, i) => `
                        <div class=\"bg-white rounded-xl border border-amber-100 p-3 recommendation-item\" style=\"animation-delay:${i*0.05}s\">\n
                            <div class=\"text-xs text-amber-600 mb-1\">${g.cat}</div>
                            <div class=\"text-sm font-semibold text-gray-800\">${g.name}</div>
                            <div class=\"text-xs text-gray-600 mt-1\">适配理由：${g.reason}</div>
                        </div>
                    `).join('');
                }
            }

            function renderStars(elementId, rating) {
                const container = document.getElementById(elementId);
                if (!container) return;
                const max = 5;
                const full = Math.max(0, Math.min(max, Math.round(rating)));
                const empty = max - full;
                let html = '';
                for (let i = 0; i < full; i++) html += '<i class="fa fa-star"></i>';
                for (let i = 0; i < empty; i++) html += '<i class="fa fa-star-o opacity-60"></i>';
                container.innerHTML = html;
            }

            function getMockFortuneData(zodiacId, range) {
                const weight = { today: 0, week: 0.3, month: 0.6, year: 0.8 }[range] || 0;
                const base = {
                    aries:      { overall: 4, love: 5, career: 3, wealth: 3 },
                    taurus:     { overall: 3, love: 3, career: 4, wealth: 4 },
                    gemini:     { overall: 4, love: 4, career: 3, wealth: 2 },
                    cancer:     { overall: 3, love: 4, career: 3, wealth: 3 },
                    leo:        { overall: 5, love: 4, career: 4, wealth: 3 },
                    virgo:      { overall: 4, love: 3, career: 5, wealth: 4 },
                    libra:      { overall: 3, love: 5, career: 3, wealth: 3 },
                    scorpio:    { overall: 4, love: 3, career: 4, wealth: 2 },
                    sagittarius:{ overall: 4, love: 4, career: 3, wealth: 4 },
                    capricorn:  { overall: 3, love: 2, career: 5, wealth: 5 },
                    aquarius:   { overall: 4, love: 3, career: 4, wealth: 3 },
                    pisces:     { overall: 3, love: 4, career: 2, wealth: 3 }
                }[zodiacId] || { overall: 3, love: 3, career: 3, wealth: 3 };
                // 根据范围微调评分
                const smooth = (v) => Math.max(1, Math.min(5, Math.round(v * (1 - weight) + 3.5 * weight)));
                const ratings = { overall: smooth(base.overall), love: smooth(base.love), career: smooth(base.career), wealth: smooth(base.wealth) };

                const summaries = {
                    aries: '精力充沛，适合开启新计划，主动出击能带来惊喜。',
                    taurus: '稳中求进的一天，耐心处理细节，成果渐显。',
                    gemini: '沟通顺畅，灵感不断，注意分清主次避免分散。',
                    cancer: '情感细腻，适合关照家人，与朋友互动增进理解。',
                    leo: '自信高涨，表现机会多，把握舞台展现自我。',
                    virgo: '条理清晰，适合完成复杂任务，保持专注。',
                    libra: '人际运良好，合作有利，适合协调与谈判。',
                    scorpio: '洞察力强，适合深入研究，避免情绪化。',
                    sagittarius: '自由发挥能量，适合探索学习与短途出行。',
                    capricorn: '务实高效，工作推进顺利，重视长期收益。',
                    aquarius: '创意闪现，尝试新方法，注意落实细节。',
                    pisces: '感性增强，适合艺术表达，留意现实安排。'
                };

                const luckySets = {
                    aries: { color: '红色', number: 7, direction: '东方' },
                    taurus: { color: '绿色', number: 6, direction: '东南' },
                    gemini: { color: '黄色', number: 3, direction: '西北' },
                    cancer: { color: '银色', number: 2, direction: '西南' },
                    leo: { color: '金色', number: 1, direction: '正南' },
                    virgo: { color: '米色', number: 5, direction: '东北' },
                    libra: { color: '粉色', number: 8, direction: '正西' },
                    scorpio: { color: '紫色', number: 9, direction: '正北' },
                    sagittarius: { color: '橙色', number: 4, direction: '西南' },
                    capricorn: { color: '棕色', number: 8, direction: '东北' },
                    aquarius: { color: '蓝色', number: 6, direction: '东南' },
                    pisces: { color: '青色', number: 2, direction: '西北' }
                };

                const adviceSets = {
                    aries: { work: '上午推进重点任务，下午安排沟通协作。', love: '主动表达与倾听更靠近彼此。', health: '适度有氧运动并保证早睡。' },
                    taurus: { work: '细节把控到位，循序渐进更有效。', love: '稳定踏实的陪伴最动人。', health: '清淡饮食，注意肠胃。' },
                    gemini: { work: '聚焦三件最重要的事避免分散。', love: '多一些耐心，少一些猜测。', health: '拉伸颈肩，缓解久坐疲劳。' },
                    cancer: { work: '先易后难，循序推进效率更高。', love: '表达关心，制造温暖的小惊喜。', health: '补充蛋白与蔬果，规律作息。' },
                    leo: { work: '抓住表现机会，准备好关键发言。', love: '体贴与自信并存更加分。', health: '适度力量训练提升状态。' },
                    virgo: { work: '建立检查清单，质量第一。', love: '放松标准，接纳不完美。', health: '注意腰背，保持正确坐姿。' },
                    libra: { work: '协调资源，双赢共好。', love: '安排一场轻松约会增进默契。', health: '适当户外走走，舒展身心。' },
                    scorpio: { work: '深挖问题根源，提出解决方案。', love: '坦诚沟通，避免猜疑。', health: '冥想放松，保持情绪平稳。' },
                    sagittarius: { work: '尝试新工具或方法提升效率。', love: '共享兴趣，增进互动。', health: '短途运动或骑行放松。' },
                    capricorn: { work: '规划长期目标，稳步推进。', love: '表达温柔与支持。', health: '规律作息与轻度拉伸。' },
                    aquarius: { work: '创新思维，注意落地细节。', love: '倾听对方观点，求同存异。', health: '减少熬夜，多喝水。' },
                    pisces: { work: '先整理资料再动手执行。', love: '用艺术小礼物表达心意。', health: '舒缓瑜伽与早睡早起。' }
                };

                const rangePrefix = { today: '今天', week: '本周', month: '本月', year: '今年' }[range] || '今天';
                // 扩展不同范围的数据结构
                const todayExtra = {
                    luckyTime: zodiacId === 'cancer' ? '14:00 - 16:00' : '10:00 - 12:00',
                    do: [
                        zodiacId === 'cancer' ? '洽谈合作' : '推进重点任务',
                        '整理计划',
                        '高质量沟通'
                    ],
                    dont: [
                        zodiacId === 'cancer' ? '冲动消费' : '情绪化决策',
                        '迟到拖延'
                    ]
                };
                const weekData = {
                    trends: {
                        love: '情感互动增多，真诚交流化解误会。',
                        career: '中旬或有小转折，提前准备应对方案。',
                        health: '注意作息与饮食均衡，适度运动。'
                    },
                    keyDates: [
                        '周二：沟通顺利，适合推进会议',
                        '周四：适合复盘与优化流程',
                        '周六：放松社交，增进感情'
                    ]
                };
                const monthData = {
                    astro: '当月星象强调结构与效率，务实推进最有利。',
                    strategies: [
                        '为关键项目设置里程碑与检查点',
                        '在15日前完成重要协商事项',
                        '月底做好总结与资源再分配'
                    ]
                };
                const yearData = {
                    guidance: '年度主线是稳中求进与能力深化，专注长期目标。',
                    focus: [
                        'Q1 夯实基础与学习升级',
                        'Q2-Q3 把握合作与曝光机会',
                        'Q4 收官与复盘，规划下一年度'
                    ]
                };
                // 星象解读示例数据（含水星逆行）
                const astroData = {
                    aspects: [
                        '金星拱木星：利于人际与审美，适合社交合作',
                        '火星刑土星：行动受阻，需耐心推进与风险控制'
                    ],
                    retrograde: (function(){
                        // 简化：假设部分日期段为水星逆行期，示例内容
                        const d = new Date();
                        const month = d.getMonth() + 1; // 1-12
                        const isMercuryRetro = [1, 4, 8, 12].includes(month); // 示例月份逆行
                        if (!isMercuryRetro) return null;
                        return {
                            planet: '水星逆行',
                            impact: '当前处于水星逆行期：沟通、出行、电子设备可能更易出现延迟与误差。',
                            tips: [
                                '重要文件与合同多次校对，避免误解与遗漏',
                                '提前规划行程，预留转乘与交通延误的缓冲',
                                '电子产品备份资料，谨慎进行系统或固件更新',
                                '沟通中复述关键信息，减少因表述差异引发的误会'
                            ]
                        };
                    })()
                };
                return {
                    ratings,
                    summary: `${rangePrefix}：${summaries[zodiacId] || '调整节奏，保持专注，稳步推进。'}`,
                    lucky: luckySets[zodiacId] || { color: '蓝色', number: 6, direction: '东南' },
                    advice: adviceSets[zodiacId] || { work: '聚焦当下重点。', love: '真诚沟通理解。', health: '规律作息运动。' },
                    today: todayExtra,
                    week: weekData,
                    month: monthData,
                    year: yearData,
                    astro: astroData
                };
            }

            // 独立组件：星象解读 规则 + 渲染
            function computeAstroInsights(zodiacId, range, baseAstro) {
                // 基础相位与逆行来自 mock，再结合规则做增强
                const now = new Date();
                const month = now.getMonth() + 1;
                const zodiacHints = {
                    virgo: '细节优先：将大任务拆成清单，逐条核对',
                    aries: '冲动易增：行动前深呼吸三次，复盘关键影响',
                    pisces: '情绪易感：安排舒缓活动，降低信息过载',
                    capricorn: '结构优先：先定目标-里程碑-复盘节奏'
                };
                const zHint = zodiacHints[zodiacId] || '';

                // 逆行：基于月份简单判断多颗行星
                const retroList = [];
                const isMercury = [1,4,8,12].includes(month);
                const isVenus = [7].includes(month);
                const isMars = [11].includes(month);
                const isJupiter = [5].includes(month);
                const isSaturn = [6,9].includes(month);
                if (isMercury) retroList.push({
                    planet: '水星逆行',
                    impact: '沟通、出行、电子设备更易出差错或延迟。',
                    tips: [
                        '重要文件多次校对与备份',
                        '出行预留中转缓冲时间',
                        '电子设备提前备份与检查',
                        zHint && `星座提示：${zHint}`
                    ].filter(Boolean)
                });
                if (isVenus) retroList.push({
                    planet: '金星逆行',
                    impact: '人际与审美判断波动，情感议题更受关注。',
                    tips: [
                        '关系沟通以“我感受”为主，避免指责',
                        '延迟进行永久性外观改造决策',
                        '复盘价值排序，暂缓冲动消费'
                    ]
                });
                if (isMars) retroList.push({
                    planet: '火星逆行',
                    impact: '行动效率下滑，冲突与拖延并存。',
                    tips: [
                        '以短冲刺任务取代长时间硬扛',
                        '把争论转为“事实-影响-建议”的结构化讨论'
                    ]
                });
                if (isJupiter) retroList.push({
                    planet: '木星逆行',
                    impact: '扩张与乐观预期收敛，更适合复盘与内化成长。',
                    tips: [
                        '复盘年度目标，明确优先级与边界',
                        '放慢扩张节奏，聚焦已有机会的质量',
                        '学习类主题更宜回顾总结而非贪多'
                    ]
                });
                if (isSaturn) retroList.push({
                    planet: '土星逆行',
                    impact: '规则、责任与结构议题凸显，延迟与考核感增强。',
                    tips: [
                        '把任务分解到可量化检查点',
                        '对关键承诺设置缓冲时间',
                        '必要时寻求导师/上级的边界与资源澄清'
                    ]
                });

                // 相位：在基础相位上补充2条常见相位并标注影响域
                const aspects = Array.isArray(baseAstro?.aspects) ? [...baseAstro.aspects] : [];
                aspects.push(
                    '太阳拱木星：自信与机会提升，适合展示与谈合作',
                    '土星刑水星：学习/沟通受阻，拆小步并设置时限更有效',
                    '金星拱海王星：艺术与浪漫感增强，宜审美创作与关系修复',
                    '水星六合木星：表达/考试/写作加成，适合签约与阐述方案',
                    '月亮合冥王：情绪敏感与洞察提升，注意避免情绪裹挟决策',
                    '火星拱天王：行动力与突破欲提升，尝试新方法但注意安全',
                    '太阳刑海王：理想化/信息失真风险，核验来源与事实',
                    '水星刑海王：谣言与误解易发，重要信息需二次确认'
                );

                // 范围差异：本周比今日列出更多建议
                const cap = range === 'week' ? 5 : 3;
                const chosenRetro = retroList[0] || null;
                const retro = chosenRetro ? {
                    planet: chosenRetro.planet,
                    impact: chosenRetro.impact,
                    tips: chosenRetro.tips.slice(0, cap)
                } : null;

                // 人设联动：在逆行建议尾部附加1条
                try {
                    const persona = JSON.parse(localStorage.getItem('persona') || 'null');
                    if (retro && persona && Array.isArray(persona.tags)) {
                        if (persona.tags.includes('考研党')) retro.tips.push('考研党：用25/5番茄法稳态推进，避免打断');
                        if (persona.tags.includes('职场新人')) retro.tips.push('职场新人：会议要点复述+会后纪要，降低误解');
                    }
                } catch (e) { /* noop */ }

                // 相位数量也随范围变化
                const aspectsOut = aspects.slice(0, range === 'week' ? 5 : 3);

                return { aspects: aspectsOut, retro };
            }

            function renderAstroInsights(zodiacId, range, fortuneData) {
                const astroSectionEl = document.getElementById('astro-section');
                if (!astroSectionEl) return;
                // 仅在今日/本周展示
                if (!(range === 'today' || range === 'week')) {
                    astroSectionEl.classList.add('hidden');
                    return;
                }
                const insights = computeAstroInsights(zodiacId, range, fortuneData.astro);
                astroSectionEl.classList.remove('hidden');
                const aspectsEl = document.getElementById('astro-aspects');
                const retroImpactEl = document.getElementById('retrograde-impact');
                const retroTipsEl = document.getElementById('retrograde-tips');
                if (aspectsEl) aspectsEl.innerHTML = (insights.aspects || []).map(x => `<li>${x}</li>`).join('');
                if (insights.retro) {
                    if (retroImpactEl) retroImpactEl.textContent = `${insights.retro.planet} · ${insights.retro.impact}`;
                    if (retroTipsEl) retroTipsEl.innerHTML = (insights.retro.tips || []).map(x => `<li>${x}</li>`).join('');
                } else {
                    if (retroImpactEl) retroImpactEl.textContent = '';
                    if (retroTipsEl) retroTipsEl.innerHTML = '';
                }
            }

            // 好物推荐数据（按星座与分类给出示例项）
            const GOODS_DATA = {
                lifestyle: {
                    pisces: [
                        { name: '星空投影灯', reason: '契合双鱼座的浪漫氛围偏好，营造治愈空间' },
                        { name: '软毛床头靠垫', reason: '满足双鱼座对舒适与放松的追求' }
                    ],
                    aries: [
                        { name: '运动手环', reason: '白羊座精力旺盛，记录运动量帮助合理释放活力' },
                        { name: '速干运动毛巾', reason: '随时擦汗保持轻爽，适配高活力度日常' }
                    ]
                },
                study: {
                    aquarius: [
                        { name: '思维导图笔记本', reason: '帮助水瓶座梳理发散思路，提升结构化输出' },
                        { name: '降噪耳机', reason: '屏蔽外界干扰，保障灵感沉浸' }
                    ],
                    gemini: [
                        { name: '分栏活页本', reason: '便于分类与快速切换主题，适配双子思维' },
                        { name: '计时器', reason: '番茄节奏提高注意力稳定度' }
                    ]
                },
                work: {
                    capricorn: [
                        { name: '日程规划本', reason: '符合摩羯座目标管理诉求，结构清晰' },
                        { name: '皮质文件夹', reason: '提升职场专业感与秩序感' }
                    ],
                    virgo: [
                        { name: '桌面收纳盒', reason: '保持工位整洁，满足处女座的秩序偏好' },
                        { name: '便签索引贴', reason: '标记重点细节，减少遗漏' }
                    ]
                }
            };

            function pickGoodsByZodiac(zodiacId) {
                const pick = (arr, n=1) => arr && arr.length ? arr.slice(0, n) : [];
                const res = [];
                const lifestyle = GOODS_DATA.lifestyle[zodiacId] || GOODS_DATA.lifestyle.pisces || [];
                const study = GOODS_DATA.study[zodiacId] || GOODS_DATA.study.aquarius || [];
                const work = GOODS_DATA.work[zodiacId] || GOODS_DATA.work.capricorn || [];
                res.push(...pick(lifestyle, 1).map(x=>({ ...x, cat:'生活类' })));
                res.push(...pick(study, 1).map(x=>({ ...x, cat:'学习类' })));
                res.push(...pick(work, 1).map(x=>({ ...x, cat:'职场类' })));
                return res;
            }

            // 范围按钮交互
            const rangeButtons = document.querySelectorAll('.range-btn');
            function setActiveRangeButton(active) {
                rangeButtons.forEach(btn => {
                    const isActive = btn.getAttribute('data-range') === active;
                    if (isActive) {
                        btn.classList.remove('bg-white/70','border','border-amber-100');
                        btn.classList.add('bg-gradient-to-r','from-primary','to-secondary','text-white','shadow');
                    } else {
                        btn.classList.remove('bg-gradient-to-r','from-primary','to-secondary','text-white','shadow');
                        btn.classList.add('bg-white/70','border','border-amber-100');
                    }
                });
            }
            function getRangeDisplayDate(range) {
                const d = new Date();
                const yyyy = d.getFullYear();
                const mm = String(d.getMonth() + 1).padStart(2, '0');
                const dd = String(d.getDate()).padStart(2, '0');
                if (range === 'today') return `${yyyy}-${mm}-${dd}`;
                if (range === 'week') {
                    const day = d.getDay() || 7; // 周一为开始
                    const monday = new Date(d);
                    monday.setDate(d.getDate() - day + 1);
                    const sunday = new Date(monday);
                    sunday.setDate(monday.getDate() + 6);
                    const fmt = (x) => `${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,'0')}-${String(x.getDate()).padStart(2,'0')}`;
                    return `${fmt(monday)} 至 ${fmt(sunday)}`;
                }
                if (range === 'month') return `${yyyy}-${mm}`;
                if (range === 'year') return `${yyyy}`;
                return `${yyyy}-${mm}-${dd}`;
            }
            rangeButtons.forEach(btn => {
                btn.addEventListener('click', () => {
                    const newRange = btn.getAttribute('data-range');
                    if (!newRange || newRange === currentRange) return;
                    currentRange = newRange;
                    setActiveRangeButton(currentRange);
                    const newDateText = getRangeDisplayDate(currentRange);
                    if (selectorDateEl) selectorDateEl.innerHTML = `<i class=\"fa fa-calendar-o mr-1\"></i>${newDateText}`;
                    if (fortuneDateEl) fortuneDateEl.textContent = newDateText;
                    if (selectedZodiac) {
                        const nameMap = { aries:'白羊座', taurus:'金牛座', gemini:'双子座', cancer:'巨蟹座', leo:'狮子座', virgo:'处女座', libra:'天秤座', scorpio:'天蝎座', sagittarius:'射手座', capricorn:'摩羯座', aquarius:'水瓶座', pisces:'双鱼座' };
                        updateFortuneData(selectedZodiac, nameMap[selectedZodiac] || '', currentRange);
                    }
                });
            });

            // 精简模式切换
            const toggleCompactBtn = document.getElementById('toggle-compact');
            const fortuneTabEl = document.getElementById('fortune-tab');
            if (toggleCompactBtn && fortuneTabEl) {
                toggleCompactBtn.addEventListener('click', () => {
                    const compact = fortuneTabEl.classList.toggle('compact-mode');
                    toggleCompactBtn.innerHTML = compact
                        ? '<i class="fa fa-expand mr-1 text-amber-500"></i>展开模式'
                        : '<i class="fa fa-compress mr-1 text-amber-500"></i>精简模式';
                });
            }

            // 为底部星座按钮绑定点击事件
            const zodiacButtons = document.querySelectorAll('.zodiac-btn');
            zodiacButtons.forEach(btn => {
                btn.addEventListener('click', () => {
                    const id = btn.getAttribute('data-zodiac');
                    const nameMap = {
                        aries: '白羊座', taurus: '金牛座', gemini: '双子座', cancer: '巨蟹座',
                        leo: '狮子座', virgo: '处女座', libra: '天秤座', scorpio: '天蝎座',
                        sagittarius: '射手座', capricorn: '摩羯座', aquarius: '水瓶座', pisces: '双鱼座'
                    };
                    const name = nameMap[id] || '';
                    selectZodiac(id, name);
                });
            });

            // 首次进入时，渲染默认星座与范围（与展示一致）
            setActiveRangeButton(currentRange);
            selectedZodiac = 'aries';
            updateFortuneData('aries', '白羊座', currentRange);

            // 伴侣模块已移除：占位以保持兼容
            try { /* noop */ } catch (e) { /* noop */ }

            // 人设：初始化、保存与展示
            const personaZodiacSelect = document.getElementById('persona-zodiac');
            const personaTagsWrap = document.getElementById('persona-tags');
            const personaSummary = document.getElementById('persona-summary');
            const savePersonaBtn = document.getElementById('save-persona');
            const profileZodiacStatus = document.getElementById('profile-zodiac-status');

            const Z_LIST = [
                { id:'aries', name:'白羊座' },{ id:'taurus', name:'金牛座' },{ id:'gemini', name:'双子座' },{ id:'cancer', name:'巨蟹座' },
                { id:'leo', name:'狮子座' },{ id:'virgo', name:'处女座' },{ id:'libra', name:'天秤座' },{ id:'scorpio', name:'天蝎座' },
                { id:'sagittarius', name:'射手座' },{ id:'capricorn', name:'摩羯座' },{ id:'aquarius', name:'水瓶座' },{ id:'pisces', name:'双鱼座' }
            ];
            if (personaZodiacSelect) {
                personaZodiacSelect.innerHTML = `<option value="">未选择</option>` + Z_LIST.map(z=>`<option value="${z.id}">${z.name}</option>`).join('');
            }
            function renderPersonaSummary(persona){
                if (!persona || !persona.zodiac) { if (personaSummary) personaSummary.textContent = '未设置'; return; }
                const name = (Z_LIST.find(z=>z.id===persona.zodiac)?.name) || '';
                const tags = (persona.tags||[]).join(' · ');
                const txt = `${name}${tags? ' · '+tags: ''}`;
                if (personaSummary) personaSummary.textContent = txt || '未设置';
                if (profileZodiacStatus) profileZodiacStatus.textContent = name || '未设置';
            }
            function loadPersona(){
                try { return JSON.parse(localStorage.getItem('persona')||'null'); } catch(e){ return null; }
            }
            function savePersona(p){ localStorage.setItem('persona', JSON.stringify(p)); }
            let persona = loadPersona();
            if (personaZodiacSelect && persona?.zodiac) personaZodiacSelect.value = persona.zodiac;
            if (personaTagsWrap && persona?.tags) {
                personaTagsWrap.querySelectorAll('.tag-btn').forEach(btn=>{
                    if (persona.tags.includes(btn.getAttribute('data-tag'))) {
                        btn.classList.add('border-primary','text-primary');
                    }
                    btn.addEventListener('click', ()=>{
                        btn.classList.toggle('border-primary');
                        btn.classList.toggle('text-primary');
                    });
                });
            } else if (personaTagsWrap) {
                personaTagsWrap.querySelectorAll('.tag-btn').forEach(btn=>{
                    btn.addEventListener('click', ()=>{
                        btn.classList.toggle('border-primary');
                        btn.classList.toggle('text-primary');
                    });
                });
            }
            renderPersonaSummary(persona);

            if (savePersonaBtn) {
                savePersonaBtn.addEventListener('click', () => {
                    const z = personaZodiacSelect ? personaZodiacSelect.value : '';
                    const tags = personaTagsWrap ? Array.from(personaTagsWrap.querySelectorAll('.tag-btn.border-primary')).map(b=>b.getAttribute('data-tag')) : [];
                    const p = { zodiac: z, tags };
                    savePersona(p);
                    persona = p;
                    renderPersonaSummary(persona);
                    // 如果运势页当前的 selectedZodiac 未设置且选择了星座，同步一下
                    if (!selectedZodiac && z) {
                        selectedZodiac = z;
                        const nameMap = { aries:'白羊座', taurus:'金牛座', gemini:'双子座', cancer:'巨蟹座', leo:'狮子座', virgo:'处女座', libra:'天秤座', scorpio:'天蝎座', sagittarius:'射手座', capricorn:'摩羯座', aquarius:'水瓶座', pisces:'双鱼座' };
                        updateFortuneData(selectedZodiac, nameMap[selectedZodiac] || '', currentRange);
                    } else if (z && selectedZodiac) {
                        const nameMap = { aries:'白羊座', taurus:'金牛座', gemini:'双子座', cancer:'巨蟹座', leo:'狮子座', virgo:'处女座', libra:'天秤座', scorpio:'天蝎座', sagittarius:'射手座', capricorn:'摩羯座', aquarius:'水瓶座', pisces:'双鱼座' };
                        updateFortuneData(selectedZodiac, nameMap[selectedZodiac] || '', currentRange);
                    }
                });
            }

            // 我的：星座好物推荐底部模态
            const openGoodsBtn = document.getElementById('open-goods-modal');
            const goodsSheet = document.getElementById('goods-bottom-sheet');
            const goodsPanel = document.getElementById('goods-bottom-sheet-panel');
            const closeGoodsBtn = document.getElementById('close-goods-modal');
            const goodsModalList = document.getElementById('goods-modal-list');
            function renderGoodsModal(){
                if (!goodsModalList) return;
                const z = selectedZodiac || (loadPersona()?.zodiac) || 'aries';
                const goods = pickGoodsByZodiac(z);
                // 仅展示少量数据（按需求，这里最多1-3条即可）
                goodsModalList.innerHTML = goods.slice(0, 3).map(g => `
                    <div class="flex items-start gap-3 bg-white rounded-xl border border-amber-100 p-3">
                        <div class="w-9 h-9 rounded-full bg-gradient-to-br from-amber-100 to-orange-100 flex items-center justify-center text-amber-600 flex-shrink-0"><i class="fa fa-gift"></i></div>
                        <div>
                            <div class="text-sm font-semibold text-gray-800">${g.name} <span class="ml-2 text-[11px] text-amber-600">${g.cat}</span></div>
                            <div class="text-xs text-gray-600 mt-1">适配理由：${g.reason}</div>
                        </div>
                    </div>
                `).join('');
            }
            if (openGoodsBtn && goodsSheet && goodsPanel) {
                openGoodsBtn.addEventListener('click', () => {
                    renderGoodsModal();
                    goodsSheet.classList.remove('hidden');
                    requestAnimationFrame(() => goodsPanel.classList.remove('translate-y-full'));
                });
            }
            if (closeGoodsBtn && goodsSheet && goodsPanel) {
                closeGoodsBtn.addEventListener('click', () => {
                    goodsPanel.classList.add('translate-y-full');
                    setTimeout(() => goodsSheet.classList.add('hidden'), 300);
                });
            }
            if (goodsSheet && goodsPanel) {
                goodsSheet.addEventListener('click', (e) => {
                    if (e.target === goodsSheet) {
                        goodsPanel.classList.add('translate-y-full');
                        setTimeout(() => goodsSheet.classList.add('hidden'), 300);
                    }
                });
            }

            // 刷新好物按钮
            const refreshGoodsBtn = document.getElementById('refresh-goods');
            if (refreshGoodsBtn) {
                refreshGoodsBtn.addEventListener('click', () => {
                    const z = selectedZodiac || (loadPersona()?.zodiac) || 'aries';
                    const nameMap = { aries:'白羊座', taurus:'金牛座', gemini:'双子座', cancer:'巨蟹座', leo:'狮子座', virgo:'处女座', libra:'天秤座', scorpio:'天蝎座', sagittarius:'射手座', capricorn:'摩羯座', aquarius:'水瓶座', pisces:'双鱼座' };
                    updateFortuneData(z, nameMap[z] || '', currentRange);
                });
            }
        });
    </script>
</body>
</html>
